Submission #580614

#TimeUsernameProblemLanguageResultExecution timeMemory
580614drdilyorDivide and conquer (IZhO14_divide)C++17
17 / 100
4 ms340 KiB
#if defined(ONPC) && !defined(_GLIBCXX_ASSERTIONS) #define _GLIBCXX_ASSERTIONS #endif #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> #ifdef ONPC #include "t_debug.cpp" #else #define debug(...) 42 #endif #define allit(a) (a).begin(), (a).end() #define sz(a) ((int) (a).size()) using namespace std; using ll = long long; using vi = vector<int>; namespace pd = __gnu_pbds; template<typename K> using ordered_set = pd::tree<K, pd::null_type, less<int>, pd::rb_tree_tag, pd::tree_order_statistics_node_update>; template<typename... T> using gp_hash_table = pd::gp_hash_table<T...>;//simple using statement gives warnings const int INF = 1e9; const ll INFL = 1e18; const int N = 1e5; const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count(); mt19937 rng(RANDOM); int solve() { int n; cin >> n; vi x(n), g(n), d(n); for (int i = 0; i < n; i++) cin >> x[i] >> g[i] >> d[i]; vector<ll> prefg(n+1), prefd(n+1); for (int i = 0; i < n; i++) { prefg[i+1] = prefg[i] + g[i]; prefd[i+1] = prefd[i] + d[i]; } ll res = 0; for (int i = 0; i < n; i++) { for (int j = i; j < n; j++) { int len = x[j] - x[i]; int energy = prefd[j+1] - prefd[i]; if (energy > len) res = max(res, prefg[j+1] - prefg[i]); } } cout << res; return 0; } signed main() { cin.tie(0)->sync_with_stdio(0); int t = 1; //cin >> t; while (t-- && cin) { if (solve()) break; #ifdef ONPC cout << "____________________" << endl; #endif } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...