#include <iostream>
#include <algorithm>
#include <stack>
#include <string>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <functional>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i=a;i<=b;i++)
#define ll long long int
#define pb(a) push_back(a)
#define vi vector<int>
#define ii pair<int,int>
#define iii pair<bool, pair<int,int> >
#define mp(a,b) make_pair(a,b)
using namespace std;
ll* st;
void init(int n){
st = new ll[4*n];
FOR(i,4*n) st[i] = 0;
}
void update(int node,int ss,int se,int i,ll val){
if(i>se || i<ss)return;
if(ss==se){st[node] = val;return;}
int mid = (ss+se)/2;
update(node*2+1,ss,mid,i,val);
update(node*2+2,mid+1,se,i,val);
st[node] = max(st[node*2+1] , st[node*2+2]);
}
int get(int node,int ss,int se,ll param){
if(st[node]+param<0){
return -1;
}else if(ss==se){
return ss;
}else{
int mid = (ss+se)/2;
return max(get(2*node+1,ss,mid,param),get(node*2+2,mid+1,se,param));
}
}
int main(){
int n;
cin >> n;
init(n);
ll x[n];
ll g[n];
ll d[n];
FOR(i,n)cin >> x[i] >> g[i] >> d[i];
int rel[n];
rel[0] = 0;
FORE(i,1,n-1){
rel[i] = d[i] - x[i] + x[i-1];
}
ll mx = 0;
FOR(i,n){
ll curr = d[i];
ll dist = 0;
ll gc = g[i];
if(curr>=dist)mx = max(mx,gc);
FORE(j,i+1,n-1){
curr += d[j];
dist += x[j] - x[j-1];
gc+=g[j];
if(curr>=dist)mx = max(mx,gc);
}
}
cout << mx<<endl;
}
Compilation message
divide.cpp: In function 'int main()':
divide.cpp:57:7: warning: variable 'rel' set but not used [-Wunused-but-set-variable]
int rel[n];
^~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
416 KB |
Output is correct |
4 |
Correct |
2 ms |
552 KB |
Output is correct |
5 |
Correct |
2 ms |
604 KB |
Output is correct |
6 |
Correct |
3 ms |
604 KB |
Output is correct |
7 |
Correct |
2 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
3 ms |
604 KB |
Output is correct |
10 |
Correct |
2 ms |
604 KB |
Output is correct |
11 |
Correct |
2 ms |
612 KB |
Output is correct |
12 |
Correct |
3 ms |
616 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
668 KB |
Output is correct |
2 |
Correct |
2 ms |
672 KB |
Output is correct |
3 |
Correct |
3 ms |
676 KB |
Output is correct |
4 |
Correct |
5 ms |
860 KB |
Output is correct |
5 |
Correct |
5 ms |
860 KB |
Output is correct |
6 |
Correct |
7 ms |
876 KB |
Output is correct |
7 |
Correct |
6 ms |
916 KB |
Output is correct |
8 |
Correct |
5 ms |
948 KB |
Output is correct |
9 |
Correct |
5 ms |
968 KB |
Output is correct |
10 |
Correct |
7 ms |
1124 KB |
Output is correct |
11 |
Correct |
27 ms |
1432 KB |
Output is correct |
12 |
Correct |
26 ms |
1548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
27 ms |
1756 KB |
Output is correct |
2 |
Correct |
95 ms |
1988 KB |
Output is correct |
3 |
Correct |
125 ms |
2252 KB |
Output is correct |
4 |
Execution timed out |
1078 ms |
5644 KB |
Time limit exceeded |
5 |
Halted |
0 ms |
0 KB |
- |