답안 #1068141

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1068141 2024-08-21T08:00:45 Z jerzyk Truck Driver (IOI23_deliveries) C++17
29 / 100
5500 ms 27524 KB
#include <bits/stdc++.h>
#include "deliveries.h"

using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
const int II = 2 * 1000 * 1000 * 1000;
const ll M = 1000LL * 1000LL * 1000LL + 7LL;
const int N = 100 * 1000 + 7;
int n;
ll tab[N], sum[N];
ll al = 0LL, answer;
vector<pair<int, ll>> ed[N];
bool vis[N];

void DFS(int v, ll ev)
{
    vis[v] = true;
    sum[v] = tab[v];
    for(int i = 0; i < (int)ed[v].size(); ++i)
    {
        if(vis[ed[v][i].st]) continue;
        DFS(ed[v][i].st, ed[v][i].nd);
        sum[v] += sum[ed[v][i].st];
    }
    //cerr << answer << " dfs: " << v - 1 << " " << sum[v] << " " << al << " " << ev << "\n";
    answer += (ll)min(sum[v], al - sum[v]) * 2LL * ev;
    vis[v] = false;
}

void init(int _N, vector<int> U, vector<int> V, vector<int> T, vector<int> W)
{
    n = _N;
    for(int i = 1; i <= n; ++i) tab[i] = W[i - 1];
    tab[1] += 1LL;
    for(int i = 1; i <= n; ++i) al += tab[i];
    for(int i = 0; i < n - 1; ++i)
    {
        ed[U[i] + 1].pb(make_pair(V[i] + 1, (ll)T[i]));
        ed[V[i] + 1].pb(make_pair(U[i] + 1, (ll)T[i]));
    }
}

long long max_time(int S, int X)
{
    answer = 0LL;
    ++S; if(S == 1) ++X;
    al -= tab[S];
    tab[S] = X;
    al += tab[S];
    //cerr << "nquery\n";
    DFS(1, 0LL);
    return answer;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 10004 KB Output is correct
2 Correct 56 ms 9812 KB Output is correct
3 Correct 56 ms 10068 KB Output is correct
4 Correct 67 ms 10068 KB Output is correct
5 Correct 57 ms 10008 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2648 KB Output is correct
2 Correct 7 ms 2808 KB Output is correct
3 Correct 9 ms 2828 KB Output is correct
4 Correct 12 ms 2908 KB Output is correct
5 Correct 12 ms 2968 KB Output is correct
6 Correct 11 ms 2908 KB Output is correct
7 Correct 12 ms 2828 KB Output is correct
8 Correct 12 ms 2908 KB Output is correct
9 Correct 15 ms 2908 KB Output is correct
10 Correct 12 ms 2908 KB Output is correct
11 Correct 9 ms 2924 KB Output is correct
12 Correct 12 ms 2924 KB Output is correct
13 Correct 12 ms 2908 KB Output is correct
14 Correct 13 ms 2824 KB Output is correct
15 Correct 14 ms 2968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 10004 KB Output is correct
2 Correct 56 ms 9812 KB Output is correct
3 Correct 56 ms 10068 KB Output is correct
4 Correct 67 ms 10068 KB Output is correct
5 Correct 57 ms 10008 KB Output is correct
6 Correct 2 ms 2652 KB Output is correct
7 Correct 26 ms 2964 KB Output is correct
8 Correct 2534 ms 4964 KB Output is correct
9 Execution timed out 5586 ms 20784 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 10004 KB Output is correct
2 Correct 56 ms 9812 KB Output is correct
3 Correct 56 ms 10068 KB Output is correct
4 Correct 67 ms 10068 KB Output is correct
5 Correct 57 ms 10008 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 29 ms 2904 KB Output is correct
8 Correct 3035 ms 5640 KB Output is correct
9 Execution timed out 5544 ms 27524 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 10004 KB Output is correct
2 Correct 56 ms 9812 KB Output is correct
3 Correct 56 ms 10068 KB Output is correct
4 Correct 67 ms 10068 KB Output is correct
5 Correct 57 ms 10008 KB Output is correct
6 Correct 2 ms 2648 KB Output is correct
7 Correct 7 ms 2808 KB Output is correct
8 Correct 9 ms 2828 KB Output is correct
9 Correct 12 ms 2908 KB Output is correct
10 Correct 12 ms 2968 KB Output is correct
11 Correct 11 ms 2908 KB Output is correct
12 Correct 12 ms 2828 KB Output is correct
13 Correct 12 ms 2908 KB Output is correct
14 Correct 15 ms 2908 KB Output is correct
15 Correct 12 ms 2908 KB Output is correct
16 Correct 9 ms 2924 KB Output is correct
17 Correct 12 ms 2924 KB Output is correct
18 Correct 12 ms 2908 KB Output is correct
19 Correct 13 ms 2824 KB Output is correct
20 Correct 14 ms 2968 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Correct 26 ms 2964 KB Output is correct
23 Correct 2534 ms 4964 KB Output is correct
24 Execution timed out 5586 ms 20784 KB Time limit exceeded
25 Halted 0 ms 0 KB -