# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1187189 | ziyad_alharbi | Divide and conquer (IZhO14_divide) | C++20 | 0 ms | 328 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define cc main
cc()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
array<int,3>a[n];
for(int x=0;x<n;x++)cin>>a[x][0]>>a[x][1]>>a[x][2];
int l=a[0][0],i=0,r=a[0][0],sg=0,st=0,ans=0;
for(int x=0;x<n;x++)
{
sg+=a[x][1];
st+=a[x][2];
r=a[x][0];
while(r-l>st)
{
sg-=a[i][1];
st-=a[i][2];
i++;
l=a[i][0];
}
ans=max(ans,sg);
}
cout<<ans<<'\n';
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |