#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define N ((ll)(2e5+100))
#define ARRS ((ll)(2e5+100))
#define MOD ((ll)(1e9+7))
ll er[ARRS];
ll dp[ARRS];
ll dc[ARRS];
ll n;
struct va{
ll x,g,c;
};
va a[ARRS];
int main(){
//freopen("divide.in","r",stdin);
//freopen("divide.out","w+",stdout);
cin>>n;
for(int i=0; i<n; i++){
cin>>a[i].x>>a[i].g>>a[i].c;
}
ll pas=0;
er[n]=n+1;
for(int i=n-1; i>=0; i--){
er[i]=i+1;
dc[i]=a[i].c;
dp[i]=a[i].g;
while(er[er[i]]<n){
//cout<<i<<" "<<a[er[er[i]]-1].x-a[i].x<<" < "<<dc[i]<<" "<<dc[er[i]]<<" "<<er[er[i]]<<endl;
if(a[er[er[i]]-1].x-a[i].x<=dc[i]+dc[er[i]]){
dp[i]+=dp[er[i]];
dc[i]+=dc[er[i]];
er[i]=er[er[i]];
}
}
pas=max(pas,dp[i]);
}
cout<<pas;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
11396 KB |
Output is correct |
2 |
Execution timed out |
1000 ms |
11396 KB |
Execution timed out |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
11396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
11396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |