이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5;
ll F[N+N],X[N],G[N],D[N],T[N+N],t,n,i,j,ans;
ll qry(int x){
ll t = 1LL << 55;
for(; x ; x -= x&-x)
t = min(t , F[x]);
return t;
}
void up(int x, ll a){
for(; x <= t ; x += x&-x)
F[x] = min(F[x] , a);
}
int main(){
scanf("%lld",&n);
for(i=1;i<=n;i++){
scanf("%lld%lld%lld",&X[i],&G[i],&D[i]);
G[i] += G[i-1];
D[i] += D[i-1];
T[++t] = D[i]-X[i];
T[++t] = D[i-1]-X[i];
}
sort(T+1 , T+t+1);
memset(F , 127 , sizeof F);
for(i=1;i<=n;i++){
j = lower_bound(T+1 , T+t+1 , D[i-1]-X[i]) - T;
up(j,G[i-1]);
j = lower_bound(T+1 , T+t+1 , D[i]-X[i]) - T;
ans = max(ans , G[i] - qry(j));
}
printf("%lld", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
divide.cpp: In function 'int main()':
divide.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&n);
~~~~~^~~~~~~~~~~
divide.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld%lld",&X[i],&G[i],&D[i]);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |