Submission #954081

# Submission time Handle Problem Language Result Execution time Memory
954081 2024-03-27T08:57:15 Z Darren0724 Truck Driver (IOI23_deliveries) C++17
29 / 100
5500 ms 25212 KB
#include "deliveries.h"
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
long long tot=0,ans=0;
vector<int> sz(N),w;
vector<pair<int,int>> adj[N];
void dfs(int k,int pa,int t){
	sz[k]=w[k];
	for(auto [j,c]:adj[k]){
		if(j==pa)continue;
		dfs(j,k,c);
		sz[k]+=sz[j];
	}
	long long y=min(1ll*sz[k],tot-sz[k]);
	ans+=y*t*2;
}
void init(int N, vector<int> U, vector<int> V, vector<int> T, vector<int> W) {
	w=W;
	for(int i=0;i<N-1;i++){
		adj[U[i]].push_back({V[i],T[i]});
		adj[V[i]].push_back({U[i],T[i]});
	}
	for(int i=0;i<N;i++){
		tot+=w[i];
	}
	w[0]++;
	tot++;
	return;
}

long long max_time(int S, int X) {
	ans=0;
	X+=(S==0);
	tot-=w[S];
	w[S]=X;
	tot+=X;
	dfs(0,0,0);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 71 ms 13320 KB Output is correct
2 Correct 75 ms 12876 KB Output is correct
3 Correct 73 ms 13044 KB Output is correct
4 Correct 72 ms 13064 KB Output is correct
5 Correct 73 ms 13136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3160 KB Output is correct
2 Correct 6 ms 3164 KB Output is correct
3 Correct 9 ms 3164 KB Output is correct
4 Correct 10 ms 3164 KB Output is correct
5 Correct 10 ms 3164 KB Output is correct
6 Correct 10 ms 3160 KB Output is correct
7 Correct 10 ms 3312 KB Output is correct
8 Correct 10 ms 3164 KB Output is correct
9 Correct 16 ms 3872 KB Output is correct
10 Correct 10 ms 3164 KB Output is correct
11 Correct 8 ms 3412 KB Output is correct
12 Correct 9 ms 3164 KB Output is correct
13 Correct 10 ms 3164 KB Output is correct
14 Correct 14 ms 3164 KB Output is correct
15 Correct 15 ms 3160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 13320 KB Output is correct
2 Correct 75 ms 12876 KB Output is correct
3 Correct 73 ms 13044 KB Output is correct
4 Correct 72 ms 13064 KB Output is correct
5 Correct 73 ms 13136 KB Output is correct
6 Correct 1 ms 3164 KB Output is correct
7 Correct 22 ms 3164 KB Output is correct
8 Correct 2045 ms 5204 KB Output is correct
9 Execution timed out 5556 ms 18228 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 13320 KB Output is correct
2 Correct 75 ms 12876 KB Output is correct
3 Correct 73 ms 13044 KB Output is correct
4 Correct 72 ms 13064 KB Output is correct
5 Correct 73 ms 13136 KB Output is correct
6 Correct 1 ms 3164 KB Output is correct
7 Correct 27 ms 3408 KB Output is correct
8 Correct 2862 ms 5720 KB Output is correct
9 Execution timed out 5590 ms 25212 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 13320 KB Output is correct
2 Correct 75 ms 12876 KB Output is correct
3 Correct 73 ms 13044 KB Output is correct
4 Correct 72 ms 13064 KB Output is correct
5 Correct 73 ms 13136 KB Output is correct
6 Correct 3 ms 3160 KB Output is correct
7 Correct 6 ms 3164 KB Output is correct
8 Correct 9 ms 3164 KB Output is correct
9 Correct 10 ms 3164 KB Output is correct
10 Correct 10 ms 3164 KB Output is correct
11 Correct 10 ms 3160 KB Output is correct
12 Correct 10 ms 3312 KB Output is correct
13 Correct 10 ms 3164 KB Output is correct
14 Correct 16 ms 3872 KB Output is correct
15 Correct 10 ms 3164 KB Output is correct
16 Correct 8 ms 3412 KB Output is correct
17 Correct 9 ms 3164 KB Output is correct
18 Correct 10 ms 3164 KB Output is correct
19 Correct 14 ms 3164 KB Output is correct
20 Correct 15 ms 3160 KB Output is correct
21 Correct 1 ms 3164 KB Output is correct
22 Correct 22 ms 3164 KB Output is correct
23 Correct 2045 ms 5204 KB Output is correct
24 Execution timed out 5556 ms 18228 KB Time limit exceeded
25 Halted 0 ms 0 KB -