Advertisement
a53

sir15

a53
Mar 27th, 2021
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. ifstream fin("sir.in");
  5. ofstream fout("sir.out");
  6. int N, C, v[100005],maxim, pozmaxp,pozmaxu;
  7. int main()
  8. {
  9. int i;
  10. fin>>C>>N;
  11. for(i=1; i<=N; ++i)
  12. {
  13. fin>>v[i];
  14. if(v[i]>maxim)
  15. {
  16. maxim=v[i];
  17. pozmaxp=i;
  18. pozmaxu=i;
  19. }
  20. else if(maxim==v[i])
  21. pozmaxu=i;
  22. }
  23. if(C==1)
  24. fout<<pozmaxu;
  25. else if(C==2)
  26. {
  27. int mmax=v[1], p=1;
  28. fout<<1<<" ";
  29. for(i=2; i<=N; i++)
  30. if(v[i]>mmax)
  31. {
  32. fout<<i<<" ";
  33. mmax=v[i];
  34. p=i;
  35. }
  36.  
  37. }
  38. else
  39. {
  40. if(pozmaxp==pozmaxu)
  41. fout<<0;
  42. else
  43. {
  44. int suma=0;
  45. for(i=pozmaxp+1; i<pozmaxu; i++)
  46. suma+=(maxim-v[i]);
  47. fout<<suma;
  48. }
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement