#include <bits/stdc++.h>
using namespace std;
int n;
vector <pair <int, int>> edge;
vector <int> weight;
void init (int N, int M, vector<int> U, vector<int> V, vector<int> W) {
n = N;
weight.resize(N);
for (int i = 0; i < M; i ++) {
edge.push_back({W[i], V[i]});
weight[V[i]] = W[i];
}
sort(edge.begin(), edge.end());
}
int getMinimumFuelCapacity (int X, int Y) {
if (n < 4) {
return -1;
}
if (!X or !Y) {
int max_weight = weight[Y];
int cnt = 0;
for (auto i: edge) {
if (i.second != Y) {
max_weight = max(max_weight, i.first);
cnt ++;
}
if (cnt == 2) {
break;
}
}
return max_weight;
}
else {
int max_weight = max(weight[X], weight[Y]);
for (auto i: edge) {
if (i.second != X and i.second != Y) {
max_weight = max(max_weight, i.first);
break;
}
}
return max_weight;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
110 ms |
10496 KB |
Output is correct |
4 |
Correct |
110 ms |
10656 KB |
Output is correct |
5 |
Correct |
111 ms |
10896 KB |
Output is correct |
6 |
Correct |
111 ms |
10528 KB |
Output is correct |
7 |
Correct |
113 ms |
10880 KB |
Output is correct |
8 |
Correct |
111 ms |
10644 KB |
Output is correct |
9 |
Correct |
108 ms |
10652 KB |
Output is correct |
10 |
Correct |
107 ms |
10636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |