Submission #37391

# Submission time Handle Problem Language Result Execution time Memory
37391 2017-12-25T03:51:37 Z adlet Divide and conquer (IZhO14_divide) C++14
0 / 100
0 ms 4748 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e5 + 5;

int n, x[N], g[N], e[N];

ll de[N], dg[N], ans;

int main() {
    freopen("divide.in", "r", stdin);
    freopen("divide.out", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> g[i] >> e[i];
        dg[i] += dg[i - 1] + g[i];
        de[i] += de[i - 1] + e[i];
    }
    for (int l = 1; l <= n; ++l) {
        for (int r = l; r <= n; ++r) {
            int len = x[r] - x[l];
//            cout << l << " " << r << " " << dg[r] - dg[l - 1] << "\n";
            if (len <= de[r] - de[l - 1] && dg[r] - dg[l - 1] > ans) {
                ans = dg[r] - dg[l - 1];
            }
        }
    }
    cout << ans;
}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:14:37: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("divide.in", "r", stdin);
                                     ^
divide.cpp:15:39: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("divide.out", "w", stdout);
                                       ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 4748 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 4748 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 4748 KB Execution killed because of forbidden syscall [unknown syscall - gap in table] (292)
2 Halted 0 ms 0 KB -