Submission #255261

# Submission time Handle Problem Language Result Execution time Memory
255261 2020-07-31T16:39:34 Z ttnhuy313 Divide and conquer (IZhO14_divide) C++14
48 / 100
1000 ms 6648 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long

const int N = 1e6 + 5, INF = 1e9 + 7;
int pref1[N], pref2[N], e[N], g[N], x[N];

signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    
    int n, i, j, k, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> g[i] >> e[i];
        ans = max(ans, g[i]);
        pref1[i] = pref1[i - 1] + e[i];
        pref2[i] = pref2[i - 1] + g[i];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = n; j >= i; --j) {
            if (ans >= pref2[j] - pref2[i - 1]) break;
            int z = x[j] - x[i], c = pref1[j] - pref1[i - 1];
            if (z <= c) {
                ans = pref2[j] - pref2[i - 1];
            }
        }
    }
    cout << ans << endl;
    return 0;

}

Compilation message

divide.cpp: In function 'int main()':
divide.cpp:12:12: warning: unused variable 'i' [-Wunused-variable]
     int n, i, j, k, ans = 0;
            ^
divide.cpp:12:15: warning: unused variable 'j' [-Wunused-variable]
     int n, i, j, k, ans = 0;
               ^
divide.cpp:12:18: warning: unused variable 'k' [-Wunused-variable]
     int n, i, j, k, ans = 0;
                  ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 18 ms 640 KB Output is correct
24 Correct 18 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 2 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 18 ms 640 KB Output is correct
24 Correct 18 ms 640 KB Output is correct
25 Correct 2 ms 640 KB Output is correct
26 Correct 5 ms 896 KB Output is correct
27 Correct 4 ms 896 KB Output is correct
28 Correct 19 ms 3320 KB Output is correct
29 Correct 21 ms 3584 KB Output is correct
30 Correct 45 ms 6648 KB Output is correct
31 Correct 31 ms 6008 KB Output is correct
32 Correct 33 ms 6136 KB Output is correct
33 Correct 31 ms 5880 KB Output is correct
34 Execution timed out 1090 ms 6008 KB Time limit exceeded
35 Halted 0 ms 0 KB -