이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define fi first
#define se second
#define LL long long
using namespace std;
const int N = 2e5 + 7;
const int mod = 1e9 + 7;
int n;
int x[N];
LL g[N];
LL d[N];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
//freopen( "input.txt" , "r" , stdin );
//freopen( "output.txt" , "w" , stdout );
cin >> n;
LL ans = 0;
for( int i = 1; i <= n; i++ ){
cin >> x[i] >> g[i] >> d[i];
ans = max( ans , g[i] );
}
for( int i = 1; i <= n; i++ ){
LL sum = g[i];
LL cnt = d[i];
for( int j = i + 1; j <= n; j++ ){
cnt += d[j];
sum += g[j];
if( x[j] - x[i] <= cnt ){
ans = max( ans , sum );
}
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |