Submission #344585

# Submission time Handle Problem Language Result Execution time Memory
344585 2021-01-06T06:15:04 Z bachaquer Divide and conquer (IZhO14_divide) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
 
using namespace std;
 
ll n, x, g, d;
 
struct lol {
    ll x;
    ll g;
    ll d;
};
 
int main() {
    freopen("stdin", "r", stdin);
    freopen("stdout", "w", stdout);
    cin >> n;
    vector<lol> v;
    ll mx = 0;
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> x >> g >> d;
        v.pb({x, g, d});
        if (i == 0 || v[i - 1].d + v[i].d < (v[i].x - v[i - 1].x)) {
            sum = 0;
        }
        else {
            v[i - 1].d -= (v[i].x - v[i - 1].x);
            if (v[i - 1].d < 0) {
                v[i].d += v[i - 1].d;
                v[i - 1].d = 0;
            }
        }
        sum += v[i].g;
        if (sum > mx) mx = sum;
    }
    cout << mx;
    return 0;
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     freopen("stdin", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
divide.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   18 |     freopen("stdout", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -