Submission #1040367

#TimeUsernameProblemLanguageResultExecution timeMemory
1040367vjudge1Divide and conquer (IZhO14_divide)C++17
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; long long a[n+1],b[n+1],c[n+1],d[n+1],f[n+1],g[n+1]; for(int i=0;i<n;i++) { cin >> a[i+1] >> b[i+1] >> c[i+1]; } a[0]=0;b[0]=0;c[0]=a[1]-a[0];d[0]=c[0];g[0]=0;f[0]=c[0]; for(int i=1;i<=n;i++) { g[i]=g[i-1]+b[i]; d[i]=c[i]+d[i-1]; f[i]=d[i]-a[i]; } vector<pair<long long,int> > v; for(int i=0;i<=n;i++) { v.push_back({f[i],i}); } sort(v.begin(),v.end());/* for(int i=0;i<=n;i++) { cout << v[i].first << ' ' << v[i].second << '\n'; }/**/ int mn=100000000; long long res=0; for(int i=0;i<=n;i++) { mn=min(mn,v[i].second); res=max(res,g[v[i].second]-g[max(mn-1,0)]); } cout << res; return 0; }

Compilation message (stderr)

divide.cpp:29:3: warning: "/*" within comment [-Wcomment]
   29 |  }/**/
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...