#include<bits/stdc++.h>
using namespace std;
#define int long long
#define CC main
#define Stalin ios_base::sync_with_stdio(0);cin.tie(0);
#define hitler cout
CC()
{
Stalin
int n;
cin>>n;
array<int,3>a[n];
int sg[n],df[n],mx[n+5];
for(int x=0;x<n;x++)
{
cin>>a[x][0]>>a[x][1]>>a[x][2];
sg[x]=a[x][1]+(x?sg[x-1]:0);
df[x]=a[x][2]+(x?df[x-1]-(a[x][0]-a[x-1][0]):0);
}
mx[n]=-1e18;
for(int x=n-1;x>=0;x--)mx[x]=max(mx[x+1],df[x]);
int ans=0;
for(int x=0;x<n;x++)
{
int l=x,r=n-1,md,i=x,d=df[x]-a[x][2];
while(l<=r)
{
md=(l+r)/2;
if(df[md]>=d)i=md;
if(mx[md+1]>=d)l=md+1;
else r=md-1;
}
ans=max(sg[i]-(x?sg[x-1]:0),ans);
}
hitler<<ans<<'\n';
}
컴파일 시 표준 에러 (stderr) 메시지
divide.cpp:4:12: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
4 | #define CC main
| ^~~~
divide.cpp:7:1: note: in expansion of macro 'CC'
7 | CC()
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |