# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
60785 |
2018-07-24T16:53:19 Z |
theknife2001 |
Race (IOI11_race) |
C++17 |
|
199 ms |
52632 KB |
#include "race.h"
#include <bits/stdc++.h>
using namespace std;
const int M=2e5+55;
vector < pair < int , int > > vec[M];
int k[M][105];
void dfs(int u , int p , int K)
{
int v,c;
int temp;
for(auto x:vec[u])
{
v=x.first;
c=x.second;
if(v==p)
continue ;
dfs(v,u,K);
for(int i=0;i<=K-c;i++)
{
temp=k[v][i];
k[u][i+c]=min(k[u][i+c],temp+1);
}
}
}
int best_path(int n, int K, int H[][2], int L[])
{
for(int i=0;i<n;i++)
{
for(int j=1;j<=K;j++)
k[i][j]=1e9+55;
}
for(int i=0;i<n-1;i++)
{
vec[H[i][0]].push_back({H[i][1],L[i]});
vec[H[i][1]].push_back({H[i][0],L[i]});
}
dfs(0,-1,K);
int b=1e9+55;
for(int i=0;i<n;i++)
b=min(b,k[i][K]);
return (b==1e9+55?-1:b);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5076 KB |
Output is correct |
2 |
Correct |
7 ms |
5228 KB |
Output is correct |
3 |
Correct |
6 ms |
5228 KB |
Output is correct |
4 |
Correct |
7 ms |
5308 KB |
Output is correct |
5 |
Correct |
7 ms |
5316 KB |
Output is correct |
6 |
Correct |
7 ms |
5316 KB |
Output is correct |
7 |
Correct |
8 ms |
5316 KB |
Output is correct |
8 |
Correct |
6 ms |
5316 KB |
Output is correct |
9 |
Correct |
8 ms |
5328 KB |
Output is correct |
10 |
Correct |
9 ms |
5376 KB |
Output is correct |
11 |
Correct |
7 ms |
5380 KB |
Output is correct |
12 |
Correct |
7 ms |
5384 KB |
Output is correct |
13 |
Correct |
8 ms |
5392 KB |
Output is correct |
14 |
Correct |
8 ms |
5392 KB |
Output is correct |
15 |
Correct |
10 ms |
5400 KB |
Output is correct |
16 |
Correct |
8 ms |
5404 KB |
Output is correct |
17 |
Correct |
7 ms |
5408 KB |
Output is correct |
18 |
Correct |
8 ms |
5412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5076 KB |
Output is correct |
2 |
Correct |
7 ms |
5228 KB |
Output is correct |
3 |
Correct |
6 ms |
5228 KB |
Output is correct |
4 |
Correct |
7 ms |
5308 KB |
Output is correct |
5 |
Correct |
7 ms |
5316 KB |
Output is correct |
6 |
Correct |
7 ms |
5316 KB |
Output is correct |
7 |
Correct |
8 ms |
5316 KB |
Output is correct |
8 |
Correct |
6 ms |
5316 KB |
Output is correct |
9 |
Correct |
8 ms |
5328 KB |
Output is correct |
10 |
Correct |
9 ms |
5376 KB |
Output is correct |
11 |
Correct |
7 ms |
5380 KB |
Output is correct |
12 |
Correct |
7 ms |
5384 KB |
Output is correct |
13 |
Correct |
8 ms |
5392 KB |
Output is correct |
14 |
Correct |
8 ms |
5392 KB |
Output is correct |
15 |
Correct |
10 ms |
5400 KB |
Output is correct |
16 |
Correct |
8 ms |
5404 KB |
Output is correct |
17 |
Correct |
7 ms |
5408 KB |
Output is correct |
18 |
Correct |
8 ms |
5412 KB |
Output is correct |
19 |
Incorrect |
7 ms |
5412 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5076 KB |
Output is correct |
2 |
Correct |
7 ms |
5228 KB |
Output is correct |
3 |
Correct |
6 ms |
5228 KB |
Output is correct |
4 |
Correct |
7 ms |
5308 KB |
Output is correct |
5 |
Correct |
7 ms |
5316 KB |
Output is correct |
6 |
Correct |
7 ms |
5316 KB |
Output is correct |
7 |
Correct |
8 ms |
5316 KB |
Output is correct |
8 |
Correct |
6 ms |
5316 KB |
Output is correct |
9 |
Correct |
8 ms |
5328 KB |
Output is correct |
10 |
Correct |
9 ms |
5376 KB |
Output is correct |
11 |
Correct |
7 ms |
5380 KB |
Output is correct |
12 |
Correct |
7 ms |
5384 KB |
Output is correct |
13 |
Correct |
8 ms |
5392 KB |
Output is correct |
14 |
Correct |
8 ms |
5392 KB |
Output is correct |
15 |
Correct |
10 ms |
5400 KB |
Output is correct |
16 |
Correct |
8 ms |
5404 KB |
Output is correct |
17 |
Correct |
7 ms |
5408 KB |
Output is correct |
18 |
Correct |
8 ms |
5412 KB |
Output is correct |
19 |
Incorrect |
199 ms |
52632 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
5076 KB |
Output is correct |
2 |
Correct |
7 ms |
5228 KB |
Output is correct |
3 |
Correct |
6 ms |
5228 KB |
Output is correct |
4 |
Correct |
7 ms |
5308 KB |
Output is correct |
5 |
Correct |
7 ms |
5316 KB |
Output is correct |
6 |
Correct |
7 ms |
5316 KB |
Output is correct |
7 |
Correct |
8 ms |
5316 KB |
Output is correct |
8 |
Correct |
6 ms |
5316 KB |
Output is correct |
9 |
Correct |
8 ms |
5328 KB |
Output is correct |
10 |
Correct |
9 ms |
5376 KB |
Output is correct |
11 |
Correct |
7 ms |
5380 KB |
Output is correct |
12 |
Correct |
7 ms |
5384 KB |
Output is correct |
13 |
Correct |
8 ms |
5392 KB |
Output is correct |
14 |
Correct |
8 ms |
5392 KB |
Output is correct |
15 |
Correct |
10 ms |
5400 KB |
Output is correct |
16 |
Correct |
8 ms |
5404 KB |
Output is correct |
17 |
Correct |
7 ms |
5408 KB |
Output is correct |
18 |
Correct |
8 ms |
5412 KB |
Output is correct |
19 |
Incorrect |
7 ms |
5412 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |