Submission #1010510

# Submission time Handle Problem Language Result Execution time Memory
1010510 2024-06-29T07:28:59 Z thinknoexit Closing Time (IOI23_closing) C++17
21 / 100
1000 ms 13396 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int n;
ll qs[3030];
ll qsx[3030], qsy[3030], qsmx[3030];
ll vx[3030], vy[3030];
int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W) {
    n = N;
    int x = X + 1, y = Y + 1;
    for (int i = 1;i < n;i++) {
        qs[i] = qs[i - 1] + W[i - 1];
    }
    for (int i = 1;i <= n;i++) {
        vx[i] = qs[max(x, i) - 1] - qs[min(x, i) - 1];
        vy[i] = qs[max(y, i) - 1] - qs[min(y, i) - 1];
        qsx[i] = qsx[i - 1] + vx[i];
        qsy[i] = qsy[i - 1] + vy[i];
        qsmx[i] = qsmx[i - 1] + max(vx[i], vy[i]);
    }
    int mx = 0;
    // not intercept
    {
        vector<bool> vis(n + 1, false);
        priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
        pq.push({ 0ll, x });
        pq.push({ 0ll, -y });
        ll cost = 0;
        while (!pq.empty()) {
            auto x = pq.top();
            pq.pop();
            int v = x.second, vv = abs(x.second);
            if (vis[vv]) continue;
            vis[vv] = 1;
            if (cost + x.first > K) break;
            cost += x.first;
            mx++;
            if (vv != 1 && !vis[vv - 1])
                pq.push({ (v < 0) ? vy[vv - 1] : vx[vv - 1], (v < 0) ? v + 1 : v - 1 });
            if (vv != n && !vis[vv + 1])
                pq.push({ (v < 0) ? vy[vv + 1] : vx[vv + 1], (v < 0) ? v - 1 : v + 1 });
        }
    }
    // intercept    
    for (int l = 1;l <= n;l++) {
        if (l > y) continue;
        for (int r = l;r <= n;r++) {
            if (r < x) continue;
            int cnt = (r - l + 1) * 2;
            ll cost = qsmx[r] - qsmx[l - 1];
            if (r < y) cost += qsy[y] - qsy[r], cnt += y - r;
            if (x < l) cost += qsx[l - 1] - qsx[x - 1], cnt += l - x;
            if (cost > K) continue;
            int pl = min(x, l) - 1;
            int pr = max(y, r) + 1;
            while (pl >= 1 && pr <= n) {
                if (vx[pl] < vy[pr]) {
                    if (cost + vx[pl] > K) break;
                    cost += vx[pl--]; cnt++;
                }
                else {
                    if (cost + vy[pr] > K) break;
                    cost += vy[pr++]; cnt++;
                }
            }
            while (pl >= 1) {
                if (cost + vx[pl] > K) break;
                cost += vx[pl--]; cnt++;
            }
            while (pr <= n) {
                if (cost + vy[pr] > K) break;
                cost += vy[pr++]; cnt++;
            }
            mx = max(mx, cnt);
        }
    }
    return mx;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 Runtime error 52 ms 13396 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 448 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 448 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 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 0 ms 348 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 12 ms 500 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 448 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 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 0 ms 348 KB Output is correct
19 Correct 5 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 12 ms 500 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 444 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Execution timed out 1093 ms 604 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 344 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 344 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 344 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 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -