Submission #167200

#TimeUsernameProblemLanguageResultExecution timeMemory
167200muhammad_hokimiyonDivide and conquer (IZhO14_divide)C++14
48 / 100
1073 ms2296 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...