Submission #747373

# Submission time Handle Problem Language Result Execution time Memory
747373 2023-05-24T06:17:58 Z baluteshih Mizuyokan 2 (JOI23_mizuyokan2) C++14
15 / 100
4000 ms 5456 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define ALL(v) v.begin(), v.end()
#define pb push_back

int arr[250005], dp[250005];

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> arr[i];
    int q;
    cin >> q;
    for (int i = 1; i <= q; ++i) {
        int x, y, a, b;
        cin >> x >> y >> a >> b;
        arr[x] = y;
        int ans = 1;
        ll cur = 0, sum = 0;
        for (int j = a + 1; j <= b; ++j) sum += arr[j];
        for (int j = a + 1; j <= b; ++j) {
            dp[j] = -n;
            if (j == a + 1) dp[j] = 1;
            if (cur > arr[j]) dp[j] = 2;
            ll nw = 0;
            for (int k = j - 1; k > a; --k) {
                if (nw > arr[k] && nw > arr[j]) dp[j] = max(dp[j], dp[k] + 2);
                nw += arr[k];
            }
            cur += arr[j];
            if (sum - cur > arr[j]) ans = max(ans, dp[j] + 1);
            if (j == b) ans = max(ans, dp[j]);
        }
        cout << ans << "\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 280 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 280 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 18 ms 340 KB Output is correct
27 Correct 13 ms 340 KB Output is correct
28 Correct 18 ms 360 KB Output is correct
29 Correct 15 ms 340 KB Output is correct
30 Correct 11 ms 340 KB Output is correct
31 Correct 12 ms 340 KB Output is correct
32 Correct 9 ms 340 KB Output is correct
33 Correct 9 ms 352 KB Output is correct
34 Correct 12 ms 340 KB Output is correct
35 Correct 14 ms 340 KB Output is correct
36 Correct 7 ms 336 KB Output is correct
37 Correct 17 ms 340 KB Output is correct
38 Correct 6 ms 360 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 280 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 18 ms 340 KB Output is correct
27 Correct 13 ms 340 KB Output is correct
28 Correct 18 ms 360 KB Output is correct
29 Correct 15 ms 340 KB Output is correct
30 Correct 11 ms 340 KB Output is correct
31 Correct 12 ms 340 KB Output is correct
32 Correct 9 ms 340 KB Output is correct
33 Correct 9 ms 352 KB Output is correct
34 Correct 12 ms 340 KB Output is correct
35 Correct 14 ms 340 KB Output is correct
36 Correct 7 ms 336 KB Output is correct
37 Correct 17 ms 340 KB Output is correct
38 Correct 6 ms 360 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 23 ms 3152 KB Output is correct
42 Correct 25 ms 3380 KB Output is correct
43 Correct 99 ms 3324 KB Output is correct
44 Correct 589 ms 2884 KB Output is correct
45 Execution timed out 4059 ms 3944 KB Time limit exceeded
46 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 300 ms 4096 KB Output is correct
3 Execution timed out 4035 ms 5456 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 274 ms 4268 KB Output is correct
4 Execution timed out 4037 ms 4424 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 280 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 328 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 3 ms 340 KB Output is correct
26 Correct 18 ms 340 KB Output is correct
27 Correct 13 ms 340 KB Output is correct
28 Correct 18 ms 360 KB Output is correct
29 Correct 15 ms 340 KB Output is correct
30 Correct 11 ms 340 KB Output is correct
31 Correct 12 ms 340 KB Output is correct
32 Correct 9 ms 340 KB Output is correct
33 Correct 9 ms 352 KB Output is correct
34 Correct 12 ms 340 KB Output is correct
35 Correct 14 ms 340 KB Output is correct
36 Correct 7 ms 336 KB Output is correct
37 Correct 17 ms 340 KB Output is correct
38 Correct 6 ms 360 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 2 ms 340 KB Output is correct
41 Correct 23 ms 3152 KB Output is correct
42 Correct 25 ms 3380 KB Output is correct
43 Correct 99 ms 3324 KB Output is correct
44 Correct 589 ms 2884 KB Output is correct
45 Execution timed out 4059 ms 3944 KB Time limit exceeded
46 Halted 0 ms 0 KB -