fork(1) download
  1. //Solution By SlavicG
  2. #include "bits/stdc++.h"
  3. using namespace std;
  4.  
  5. #define ll long long
  6.  
  7. #define forn(i,n) for(int i=0;i<n;i++)
  8. #define all(v) v.begin(), v.end()
  9. #define rall(v) v.rbegin(),v.rend()
  10.  
  11. #define pb push_back
  12. #define sz(a) (int)a.size()
  13.  
  14. #define endl "\n"
  15. #define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  16.  
  17. int main()
  18. {
  19. int n;
  20. cin >> n;
  21. int a[n];
  22. for(int i = 0;i < n;i++)
  23. {
  24. cin >> a[i];
  25. }
  26. long long sum = 0;
  27. long long Max = 0;
  28. int DayIndex = -1;
  29. for(int i = 0;i<n;i++)
  30. {
  31. sum += a[i];
  32. if(Max < sum)
  33. {
  34. DayIndex = i;
  35. Max = sum;
  36. }
  37. }
  38. cout << DayIndex+1 <<"\n";
  39. }
Success #stdin #stdout 0s 4524KB
stdin
Standard input is empty
stdout
9877