Submission #1120928

#TimeUsernameProblemLanguageResultExecution timeMemory
1120928TsaganaDivide and conquer (IZhO14_divide)C++14
17 / 100
1 ms508 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; int g[100001]; int e[100001]; vector<int> v; void solve () { int n; cin >> n; for (int i = 0; i < n; i++) { int x; cin >> x >> g[i] >> e[i]; v.pb(x); } int ans = 0; for (int i = 0; i < n; i++) { int c = e[i]-1; int val = g[i]; int l = i, r = i+1; while (r < n) { if (v[r] - v[l] > c + e[r]) break ; c += e[r] - (v[r] - v[l]); val += g[r]; l = r; r = l + 1; } if (i && r == n) { l = i-1; r = i; while (l) { if (v[r] - v[l] > c + e[l]) break ; c += e[l] - (v[r] - v[l]); val += g[l]; r = l; l = r - 1; } } ans = max(ans, val); } cout << ans; } signed main() {IOS solve(); return 0;}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...