Submission #1008028

# Submission time Handle Problem Language Result Execution time Memory
1008028 2024-06-26T06:14:47 Z 12345678 Closing Time (IOI23_closing) C++17
21 / 100
1000 ms 33056 KB
#include "closing.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=2e5+5;

vector<pair<ll, ll>> d[nx];

void dfs(int u, int p, ll cw, vector<ll> &x)
{
    x[u]=cw;
    for (auto [v, w]:d[u]) if (v!=p) dfs(v, u, cw+w, x);
}

int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    if (X>Y) swap(X, Y);
    for (int i=0; i<N; i++) d[i].clear();
    for (int i=0; i<N-1; i++) d[U[i]].push_back({V[i], W[i]}), d[V[i]].push_back({U[i], W[i]});
    vector<ll> a(N), b(N);
    ll mx=0;
    dfs(X, X, 0, a);
    dfs(Y, Y, 0, b);
    //for (int i=0; i<N; i++) cout<<a[i]<<' '<<b[i]<<'\n';
    priority_queue<ll, vector<ll>, greater<ll>> pq;
    for (int i=0; i<N; i++) pq.push(a[i]), pq.push(b[i]);
    ll tmp=K;
    while (!pq.empty()&&pq.top()<=tmp) mx++, tmp-=pq.top(), pq.pop();
    for (int i=0; i<N; i++)
    {
        for (int j=i; j<N; j++)
        {
            ll c=K, res=2*(j-i+1);
            for (int k=i; k<=j; k++) c-=max(a[k], b[k]);
            for (int k=X; k<i; k++) res++, c-=a[k];
            for (int k=j+1; k<=Y; k++) res++, c-=b[k];
            if (c<0) continue;
            while (!pq.empty()) pq.pop();
            for (int k=0; k<min(X, i); k++) pq.push(a[k]);
            for (int k=max(Y, j)+1; k<N; k++) pq.push(b[k]);
            while (!pq.empty()&&c>=pq.top()) c-=pq.top(), pq.pop(), res++;
            mx=max(mx, res);
        }
    }
    return mx;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4968 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 1065 ms 33056 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 4 ms 5148 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 4952 KB Output is correct
18 Correct 2 ms 4952 KB Output is correct
19 Correct 718 ms 5176 KB Output is correct
20 Correct 18 ms 4956 KB Output is correct
21 Correct 313 ms 5176 KB Output is correct
22 Correct 26 ms 4952 KB Output is correct
23 Correct 32 ms 4956 KB Output is correct
24 Correct 27 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 2 ms 4952 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 4 ms 5148 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 4952 KB Output is correct
18 Correct 2 ms 4952 KB Output is correct
19 Correct 718 ms 5176 KB Output is correct
20 Correct 18 ms 4956 KB Output is correct
21 Correct 313 ms 5176 KB Output is correct
22 Correct 26 ms 4952 KB Output is correct
23 Correct 32 ms 4956 KB Output is correct
24 Correct 27 ms 4952 KB Output is correct
25 Correct 17 ms 5212 KB Output is correct
26 Execution timed out 1096 ms 5468 KB Time limit exceeded
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4968 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 1 ms 4968 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 1 ms 4968 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 1 ms 4968 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 1 ms 4968 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -