Submission #638943

#TimeUsernameProblemLanguageResultExecution timeMemory
638943bonkDivide and conquer (IZhO14_divide)C++14
0 / 100
1 ms316 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; vector<tuple<ll, ll, ll>>v(n); for(int i = 0; i < n; i++){ ll x, g, d; cin >> x >> g >> d; v[i] = {x, g, d}; } ll ans = 0; for(int i = 0; i < n; i++){ auto [x1, g1, d1] = v[i]; ans = max(ans, g1); ll tmp = g1; ll energy = d1; for(int j = i + 1; j < n; j++){ auto [x2, g2, d2] = v[j]; ll dis = x2 - x1; energy += d2; tmp += g1; if(energy >= dis) ans = max(ans, tmp); } } cout << ans << '\n'; return 0; }

Compilation message (stderr)

divide.cpp: In function 'int main()':
divide.cpp:18:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   18 |         auto [x1, g1, d1] = v[i];
      |              ^
divide.cpp:23:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   23 |             auto [x2, g2, d2] = v[j];
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...