Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("sir.in");
- ofstream fout("sir.out");
- int N, C, v[100005],maxim, pozmaxp,pozmaxu;
- int main()
- {
- int i;
- fin>>C>>N;
- for(i=1; i<=N; ++i)
- {
- fin>>v[i];
- if(v[i]>maxim)
- {
- maxim=v[i];
- pozmaxp=i;
- pozmaxu=i;
- }
- else if(maxim==v[i])
- pozmaxu=i;
- }
- if(C==1)
- fout<<pozmaxu;
- else if(C==2)
- {
- int mmax=v[1], p=1;
- fout<<1<<" ";
- for(i=2; i<=N; i++)
- if(v[i]>mmax)
- {
- fout<<i<<" ";
- mmax=v[i];
- p=i;
- }
- }
- else
- {
- if(pozmaxp==pozmaxu)
- fout<<0;
- else
- {
- int suma=0;
- for(i=pozmaxp+1; i<pozmaxu; i++)
- suma+=(maxim-v[i]);
- fout<<suma;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement