Submission #170231

#TimeUsernameProblemLanguageResultExecution timeMemory
170231beso123Divide and conquer (IZhO14_divide)C++14
17 / 100
221 ms3056 KiB
#include <bits/stdc++.h> #define int long long #define pii pair<int, pair<int,int> > #define x first #define y second.first #define z second.second using namespace std; int n; pii a[100005]; main(){ cin>>n; for(int k=1;k<=n;k++){ int a1,b,c; cin>>a1>>b>>c; a[k]={a1,{b,c}}; } int l=1; int ans=a[1].y,sc=a[1].z; int pas=ans; for(int r=1;r<=n;r++){ if(r!=1){ ans+=a[r].y; sc+=a[r].z; } while(l<=r && sc<a[r].x-a[l].x){ ans-=a[l].y; sc-=a[l].z; l++; } pas=max(pas,ans); } cout<<pas; return 0; }

Compilation message (stderr)

divide.cpp:10:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...