Advertisement
a53

sss1

a53
Mar 18th, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. ///100p
  2. #include <fstream>
  3. #include <iostream>
  4. using namespace std;
  5. int n, c, sum, L, sol1, sol2, x, k, sc, nr, i;
  6. int main () {
  7. ifstream fin ("sss.in");
  8. ofstream fout("sss.out");
  9. fin>>c;
  10. fin>>n;
  11.  
  12. L = 0;
  13. sum = 0;
  14. while (sum < n) {
  15. L++;
  16. sum += L;
  17. }
  18.  
  19. for (i=1;i<=n;i++) {
  20. fin>>x;
  21.  
  22. if (i == 1) {
  23. k = x;
  24. while (k%10 == 0)
  25. k /= 10;
  26. k = k%10;
  27. }
  28.  
  29. if (i+k-1 >= n)
  30. sol1 += x;
  31.  
  32. sc += x;
  33. nr++;
  34. if (nr == L) {
  35. if (sc > sol2) {
  36. sol2 = sc;
  37. }
  38. L--;
  39. nr = 0;
  40. sc = 0;
  41. }
  42. }
  43. if (c == 1)
  44. fout<<sol1<<"\n";
  45. else
  46. fout<<sol2<<"\n";
  47. return 0;
  48. }
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement