#include <bits/stdc++.h>
#include "swap.h"
using namespace std;
const int N = 100005;
int n, m, v[N];
vector <int> v2;
void init(int n1, int m1, vector<int> u1, vector<int> v1, vector<int> w1) {
for(int i = 0; i < m1; i++){
v[v1[i]] = (w1[i]);
v2.push_back(w1[i]);
}
sort(v2.begin(), v2.end());
}
int getMinimumFuelCapacity(int x, int y) {
if(m <= 2){
return -1;
}
if(x > y) swap(x,y);
int ans = (v[x]+v[y]);
bool tr = 0, tr1 = 0;
for(int i = 0; i <= 5; i++){
if((v2[i] != v[x] and v2[i] != v[y]) or (v2[i] == v[x] and ((tr == 1 and v[y] != v[x]) or (v[y] == v[x] and tr1 == 1))) or (v2[i] == v[y] and ((tr1 == 1 and v[y] != v[x]) or (v[y] == v[x] and tr == 1)))){
ans += (2*v2[i]);
break;
}
if(v2[i] == v[x]) tr = 1;
else if(v2[i] == v[y]) tr1 = 1;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
18 ms |
4044 KB |
Output is correct |
10 |
Correct |
21 ms |
5112 KB |
Output is correct |
11 |
Correct |
21 ms |
4812 KB |
Output is correct |
12 |
Correct |
23 ms |
5068 KB |
Output is correct |
13 |
Correct |
28 ms |
5068 KB |
Output is correct |
14 |
Correct |
19 ms |
4564 KB |
Output is correct |
15 |
Correct |
54 ms |
7680 KB |
Output is correct |
16 |
Correct |
56 ms |
7620 KB |
Output is correct |
17 |
Correct |
54 ms |
7988 KB |
Output is correct |
18 |
Correct |
47 ms |
7984 KB |
Output is correct |
19 |
Incorrect |
26 ms |
4432 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
53 ms |
5228 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
18 ms |
4044 KB |
Output is correct |
10 |
Correct |
21 ms |
5112 KB |
Output is correct |
11 |
Correct |
21 ms |
4812 KB |
Output is correct |
12 |
Correct |
23 ms |
5068 KB |
Output is correct |
13 |
Correct |
28 ms |
5068 KB |
Output is correct |
14 |
Correct |
19 ms |
4564 KB |
Output is correct |
15 |
Correct |
54 ms |
7680 KB |
Output is correct |
16 |
Correct |
56 ms |
7620 KB |
Output is correct |
17 |
Correct |
54 ms |
7988 KB |
Output is correct |
18 |
Correct |
47 ms |
7984 KB |
Output is correct |
19 |
Incorrect |
53 ms |
5228 KB |
Output isn't correct |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |