Submission #479981

#TimeUsernameProblemLanguageResultExecution timeMemory
479981Dima_BorchukDivide and conquer (IZhO14_divide)C++17
48 / 100
1080 ms3300 KiB
#pragma GCC optimize("Ofast") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define sz(x) int32_t(x.size()) #define pii pair < int, int > #include <bits/stdc++.h> #define ld long double #define ll long long #define _ << ' ' << #define se second #define fi first #define int ll using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; mt19937 gen(chrono::system_clock::now().time_since_epoch().count()); const int mod = (int)1e9 + 9; const int N = (int)1e6 + 5; const int INF = (int)1e16 + 5; struct point { int x, g, e; }; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector < point > a(n + 1); vector < int > pe(n + 1, 0), pg(n + 1, 0); for (int i = 1; i <= n; i++) { cin >> a[i].x >> a[i].g >> a[i].e; pe[i] = pe[i - 1] + a[i].e; pg[i] = pg[i - 1] + a[i].g; } int ans = 0; for (int i = 1; i <= n; i++) { for (int j = i; j <= n; j++) { if (pe[j] - pe[i - 1] >= a[j].x - a[i].x) { ans = max(ans, pg[j] - pg[i - 1]); } } } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...