Submission #1032134

# Submission time Handle Problem Language Result Execution time Memory
1032134 2024-07-23T12:24:03 Z Turkhuu Closing Time (IOI23_closing) C++17
0 / 100
1000 ms 17492 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), s1(N + 1), s2(N + 1);
    for (int i = 0; i < N; i++) {
        tie(one[i], two[i]) = minmax(dis(X, i), dis(Y, i));
    }
    int ans = 0;
    {
        auto a(one); sort(a.begin(), a.end());
        ll sum = 0; int cnt = 0;
        while (cnt < N && sum + a[cnt] <= K) sum += a[cnt++];
        ans = max(ans, cnt);
    }
    for (int i = 0; i <= Y; i++) {
        ll s = s1[N];
        int l = 0, r = N - 1;
        for (int j = i; j < N; j++) {
            s += two[j] - one[j];
            if (r < j) r++;
            while (s > K && (l < min(i, X) || r > max(j, Y))) {
                if (l < min(i, X) && (r == max(j, Y) || one[l] > one[r])) s -= one[l++];
                else s -= one[r--];
            }
            if (s > K) break;
            if (j >= X) ans = max(ans, j - i + 1 + r - l + 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: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1049 ms 17492 KB Time limit exceeded
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: '3', found: '4'
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: '3', found: '4'
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: '3', found: '4'
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: '11'
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: '11'
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: '11'
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: '11'
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: '11'
2 Halted 0 ms 0 KB -