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. if(L + d - 1 > n)
  25. for(int R = L; R <= n; R++) tong += a[R];
  26. else
  27. for(int R = L; R <= L + d - 1; R++) tong += a[R];
  28. if(L + d - 1 > n)
  29. for(int R = 1; R <= (L + d - 1) % n; R++) tong += a[R];
  30. if(tong > sum){
  31. sum = tong;
  32. pos = L;
  33. cnt = d;
  34. }
  35. }
  36. }
  37. cout << sum << endl;
  38. cout << pos << " " << cnt;
  39. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
Standard output is empty