Submission #927396

# Submission time Handle Problem Language Result Execution time Memory
927396 2024-02-14T19:54:09 Z aykhn Closing Time (IOI23_closing) C++17
0 / 100
125 ms 34356 KB
#include <bits/stdc++.h>
#include "closing.h"

using namespace std;

const int MXN = 2e5 + 5;

int n, x, y;
long long k;
vector<array<long long, 2>> adj[MXN];
long long d[2][MXN];

void dfs(int a, int p, int t)
{
    for (const array<long long, 2> &v : adj[a])
    {
        if (v[0] == p) continue;
        d[t][v[0]] = d[t][a] + v[1];
        dfs(v[0], a, t);
    }
}

int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W)
{
    n = N, x = X, y = Y, k = K;
    for (int i = 0; i < n; i++)
    {
        d[0][i] = d[1][i] = 0;
        adj[i].clear();
    }
    for (int i = 0; i < n - 1; i++)
    {
        adj[U[i]].push_back({V[i], W[i]});
        adj[V[i]].push_back({U[i], W[i]});
    }
    dfs(x, x, 0);
    dfs(y, y, 1);
    vector<int> v;
    for (int i = 0; i < n; i++) v.push_back(d[0][i]), v.push_back(d[1][i]);
    sort(v.begin(), v.end());
    int res = 0;
    for (int i = 0; i < n; i++)
    {
        k -= v[i];
        if (k < 0) break;
        res++;
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8028 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 125 ms 34356 KB 1st lines differ - on the 1st token, expected: '451', found: '200000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8028 KB Output is correct
2 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '30', found: '20'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8028 KB Output is correct
2 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '30', found: '20'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8028 KB Output is correct
2 Incorrect 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '30', found: '20'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8028 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 2 ms 8028 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 2 ms 8028 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 2 ms 8028 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 2 ms 8028 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -