fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. const int MAXN = 1e4 + 7;
  4. long long a[MAXN], pre[MAXN], n;
  5. long long sum = LLONG_MIN, pos, cnt;
  6.  
  7. int main(){
  8. ios_base::sync_with_stdio(0);
  9. cout.tie(0);
  10. cin.tie(0);
  11.  
  12. freopen("day.inp", "r", stdin);
  13. freopen("day.out", "w", stdout);
  14.  
  15. cin >> n;
  16. for(int i = 1; i <= n; i++){
  17. cin >> a[i];
  18. pre[i] = pre[i - 1] + a[i];
  19. }
  20.  
  21. for(int d = 1; d <= n; d++){
  22. for(int L = 1; L <= n; L++){
  23. long long tong = 0;
  24. for(int R = L; R <= (L + d - 1 > n ? n : L + d - 1); R++) tong += a[R];
  25. for(int R = 1; R <= (L + d - 1 > n ? (L + d - 1) % n : 0); R++) tong += a[R];
  26. if(tong > sum){
  27. sum = tong;
  28. pos = L;
  29. cnt = d;
  30. }
  31. }
  32. }
  33. cout << sum << endl;
  34. cout << pos << " " << cnt;
  35. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
Standard output is empty