Submission #1032059

# Submission time Handle Problem Language Result Execution time Memory
1032059 2024-07-23T10:42:16 Z Turkhuu Closing Time (IOI23_closing) C++17
21 / 100
1000 ms 1670548 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
    vector<ll> pfs(N);
    for (int i = 0; i < N - 1; i++) {
        pfs[i + 1] = pfs[i] + W[i];
    }
    auto dis = [&](int x, int y) {
        if (x > y) swap(x, y);
        return pfs[y] - pfs[x];
    };
    vector<ll> one(N), two(N), sx(N + 1), sy(N + 1), s2(N + 1), s1(N + 1);
    for (int i = 0; i < N; i++) {
        tie(one[i], two[i]) = minmax(dis(X, i), dis(Y, i));
        sx[i + 1] = sx[i] + dis(X, i);
        sy[i + 1] = sy[i] + dis(Y, i);
        s1[i + 1] = s1[i] + one[i];
        s2[i + 1] = s2[i] + two[i];
    }
    int ans = 0;
    vector<tuple<ll, int, int>> a;
    for (int lx = 0; lx <= X; lx++) {
        for (int rx = X; rx < N; rx++) {
            a.emplace_back(sx[rx + 1] - sx[lx], lx, rx);
        }
    }
    sort(a.begin(), a.end());
    int M = a.size();
    vector<int> b(M);
    for (int i = 0; i < M; i++) {
        auto [_, l, r] = a[i];
        b[i] = max(i == 0 ? 0 : b[i - 1], r - l + 1);
    }
    for (int ly = 0; ly <= Y; ly++) {
        for (int ry = Y; ry < N; ry++) {
            ll s = sy[ry + 1] - sy[ly];
            if (s > K) continue;
            ans = max(ans, ry - ly + 1 + b[upper_bound(a.begin(), a.end(), tuple<ll, int, int>{K - s, N, N}) - a.begin() - 1]);
        }
    }
    for (int l2 = 0; l2 < N; l2++) {
        for (int r2 = l2; r2 < N; r2++) {
            for (int l1 = 0; l1 <= min(X, l2); l1++) {
                ll s = s2[r2 + 1] - s2[l2] + s1[l2] - s1[l1] - s1[r2 + 1];
                int r1 = upper_bound(s1.begin(), s1.end(), K - s) - s1.begin() - 2;
                if (r1 >= max(Y, r2)) ans = max(ans, r1 - l1 + 1 + r2 - l2 + 1);
            }
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1107 ms 1670548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 356 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 356 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 190 ms 1580 KB Output is correct
20 Correct 19 ms 856 KB Output is correct
21 Correct 70 ms 1488 KB Output is correct
22 Correct 4 ms 348 KB Output is correct
23 Correct 2 ms 344 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 428 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 436 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 356 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 190 ms 1580 KB Output is correct
20 Correct 19 ms 856 KB Output is correct
21 Correct 70 ms 1488 KB Output is correct
22 Correct 4 ms 348 KB Output is correct
23 Correct 2 ms 344 KB Output is correct
24 Correct 2 ms 348 KB Output is correct
25 Correct 11 ms 348 KB Output is correct
26 Execution timed out 1090 ms 38152 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -