Submission #344562

#TimeUsernameProblemLanguageResultExecution timeMemory
344562l3nl3Divide and conquer (IZhO14_divide)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> #define exit exit(false) //#define here() cerr << "herewego\n"; #define show(x) cerr << #x << ": " << x << '\n'; #define int long long //#define double long double #define all(a) a.begin(), a.end() #define whole(a, p, q) a+p, a+p+q #define ioio() ios_base::sync_with_stdio (0); cin.tie (0); cout.tie (0); using namespace std; //using namespace __gnu_pbds; //typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; const int sz = 5e3+7; int n, x[sz], g[sz], d[sz], p[sz], pp[sz], ans, mx; signed main () { ioio(); cin >> n; for (int i = 1; i <= n; i++) { cin >> x[i] >> g[i] >> d[i]; p[i] = p[i-1] + d[i]; pp[i] = pp[i-1] + g[i]; mx = max (mx, g[i]); } for (int i = 1; i <= n; i++) { int mj = i; for (int j = n; j >= i+1; j--) { if (x[j] - x[i] <= p[j] - p[i-1]) { ans += pp[j] - pp[i-1]; mj = j; break; } } i = mj+1; } cout << (ans == 0 ? mx : ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...