Submission #125597

#TimeUsernameProblemLanguageResultExecution timeMemory
125597srvltDivide and conquer (IZhO14_divide)C++14
48 / 100
20 ms1068 KiB
#include <bits/stdc++.h> #define ll long long #define db long double #define pb push_back #define ppb pop_back #define fi first #define se second #define mp make_pair #define endl "\n" #define int long long using namespace std; const int N = 5e3 + 3; int n, x[N], d[N], g[N]; int pd[N], pg[N], ans; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n; for (int i = 1; i <= n; i++) { cin>>x[i]>>g[i]>>d[i]; pd[i] = pd[i - 1] + d[i]; pg[i] = pg[i - 1] + g[i]; } for (int i = 1; i <= n; i++) { for (int j = 1; j <= i; j++) { if (pd[i] - pd[j - 1] >= x[i] - x[j]) { ans = max(ans, pg[i] - pg[j - 1]); } } } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...