Submission #638943

# Submission time Handle Problem Language Result Execution time Memory
638943 2022-09-08T03:51:32 Z bonk Divide and conquer (IZhO14_divide) C++14
0 / 100
1 ms 316 KB
#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

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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 316 KB Output isn't correct
3 Halted 0 ms 0 KB -