답안 #917205

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917205 2024-01-27T12:37:43 Z zyq181 Truck Driver (IOI23_deliveries) C++17
29 / 100
74 ms 7764 KB
#include "deliveries.h"
#include <bits/stdc++.h>
using namespace std;

int N;
vector<pair<int, int> > adjList[1010];
long long paredge[1010];
long long sbtree[1010];
long long tot;
long long ans;
int w[1010];

void dfs(int n, int p = -1){
	sbtree[n]+=w[n];
	for(auto it: adjList[n]){
		int x, y;
		x = it.first;
		y = it.second;
		if(x == p) continue;
		paredge[x] = y;
		dfs(x, n);
		sbtree[n] += sbtree[x];
	}
}



void init(int NN, std::vector<int> U, std::vector<int> V, std::vector<int> T, std::vector<int> W) {
	N = NN;
	for(int a=0; a<N-1; a++){
		adjList[U[a]].push_back({V[a], T[a]});
		adjList[V[a]].push_back({U[a], T[a]});
	}
	W[0]++;
	for(int a=0; a<N; a++){
		w[a] = W[a];
		tot += W[a];
	}
	return;
}

long long max_time(int S, int X) {
	for(int a=0; a<N; a++) sbtree[a] = 0;
	ans = 0;
	tot -= w[S];
	w[S] = X;
	if(S == 0) w[0]++;
	tot += w[S];
	dfs(0);
	for(int a=1; a<N; a++){
		if(tot/2 < sbtree[a]){
			ans += 2LL * (tot - sbtree[a]) * paredge[a];
		}
		else{
			ans += 2LL * sbtree[a] * paredge[a];
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 7656 KB Output is correct
2 Correct 71 ms 7424 KB Output is correct
3 Correct 71 ms 7672 KB Output is correct
4 Correct 74 ms 7672 KB Output is correct
5 Correct 71 ms 7764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 5 ms 348 KB Output is correct
3 Correct 7 ms 348 KB Output is correct
4 Correct 9 ms 604 KB Output is correct
5 Correct 9 ms 616 KB Output is correct
6 Correct 9 ms 472 KB Output is correct
7 Correct 9 ms 600 KB Output is correct
8 Correct 9 ms 604 KB Output is correct
9 Correct 9 ms 604 KB Output is correct
10 Correct 9 ms 600 KB Output is correct
11 Correct 7 ms 348 KB Output is correct
12 Correct 8 ms 344 KB Output is correct
13 Correct 8 ms 348 KB Output is correct
14 Correct 11 ms 500 KB Output is correct
15 Correct 11 ms 612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 7656 KB Output is correct
2 Correct 71 ms 7424 KB Output is correct
3 Correct 71 ms 7672 KB Output is correct
4 Correct 74 ms 7672 KB Output is correct
5 Correct 71 ms 7764 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 21 ms 604 KB Output is correct
8 Runtime error 8 ms 1616 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 7656 KB Output is correct
2 Correct 71 ms 7424 KB Output is correct
3 Correct 71 ms 7672 KB Output is correct
4 Correct 74 ms 7672 KB Output is correct
5 Correct 71 ms 7764 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 26 ms 600 KB Output is correct
8 Runtime error 12 ms 1632 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 7656 KB Output is correct
2 Correct 71 ms 7424 KB Output is correct
3 Correct 71 ms 7672 KB Output is correct
4 Correct 74 ms 7672 KB Output is correct
5 Correct 71 ms 7764 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 5 ms 348 KB Output is correct
8 Correct 7 ms 348 KB Output is correct
9 Correct 9 ms 604 KB Output is correct
10 Correct 9 ms 616 KB Output is correct
11 Correct 9 ms 472 KB Output is correct
12 Correct 9 ms 600 KB Output is correct
13 Correct 9 ms 604 KB Output is correct
14 Correct 9 ms 604 KB Output is correct
15 Correct 9 ms 600 KB Output is correct
16 Correct 7 ms 348 KB Output is correct
17 Correct 8 ms 344 KB Output is correct
18 Correct 8 ms 348 KB Output is correct
19 Correct 11 ms 500 KB Output is correct
20 Correct 11 ms 612 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 21 ms 604 KB Output is correct
23 Runtime error 8 ms 1616 KB Execution killed with signal 11
24 Halted 0 ms 0 KB -