fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. long long n,x,ans=-10010,cnt=-11110;
  4. int main(){
  5. ios::sync_with_stdio(false);
  6. cin.tie(0);
  7. cout.tie(0);
  8. cin>>n;
  9. for(int i=1;i<=n;i++){
  10. cin>>x;
  11. cnt=max(x,cnt+x);
  12. if(cnt%7==0){
  13. ans=max(cnt,ans);
  14. }
  15. }
  16. cout<<ans;
  17. return 0;
  18. }
Success #stdin #stdout 0s 5316KB
stdin
7
3
5
1
6
2
14
10
stdout
-10010