#include "swap.h"
#include <vector>
const int N = 100000, INF = 0x3f3f3f3f;
int min(int a, int b) { return a < b ? a : b; }
int max(int a, int b) { return a > b ? a : b; }
int ww[N], n, m, ans, mn1, mn2, mn3, star;
void init(int n_, int m_, std::vector<int> ii, std::vector<int> jj, std::vector<int> ww_) {
int h;
n = n_, m = m_;
ans = -1, star = 0;
if (m == n - 1) {
star = 1, ans = -1;
for (h = 0; h < m; h++)
if (ii[h] != 0) {
star = 0;
break;
}
mn1 = mn2 = mn3 = INF;
for (h = 0; h < m; h++) {
ww[jj[h]] = ww_[h];
if (mn1 > ww_[h])
mn3 = mn2, mn2 = mn1, mn1 = ww_[h];
else if (mn2 > ww_[h])
mn3 = mn2, mn2 = ww_[h];
else if (mn3 > ww_[h])
mn3 = ww_[h];
}
ans = -1;
} else {
for (h = 0; h < m; h++)
ans = max(ans, ww_[h]);
if (n == 2)
ans = -1;
}
}
int getMinimumFuelCapacity(int i, int j) {
return star ? (mn3 == INF ? -1 : max(max(ww[i], ww[j]), mn3)) : ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
29 ms |
4076 KB |
Output is correct |
10 |
Correct |
36 ms |
4972 KB |
Output is correct |
11 |
Correct |
35 ms |
4972 KB |
Output is correct |
12 |
Correct |
48 ms |
5248 KB |
Output is correct |
13 |
Correct |
38 ms |
5356 KB |
Output is correct |
14 |
Correct |
35 ms |
4608 KB |
Output is correct |
15 |
Correct |
98 ms |
9196 KB |
Output is correct |
16 |
Correct |
98 ms |
8988 KB |
Output is correct |
17 |
Correct |
112 ms |
9440 KB |
Output is correct |
18 |
Correct |
111 ms |
9456 KB |
Output is correct |
19 |
Correct |
61 ms |
6068 KB |
Output is correct |
20 |
Correct |
100 ms |
9708 KB |
Output is correct |
21 |
Correct |
103 ms |
10148 KB |
Output is correct |
22 |
Correct |
111 ms |
10320 KB |
Output is correct |
23 |
Correct |
135 ms |
10320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
97 ms |
6160 KB |
Output is correct |
4 |
Correct |
101 ms |
6312 KB |
Output is correct |
5 |
Correct |
119 ms |
6412 KB |
Output is correct |
6 |
Correct |
102 ms |
6108 KB |
Output is correct |
7 |
Correct |
100 ms |
6376 KB |
Output is correct |
8 |
Correct |
125 ms |
6024 KB |
Output is correct |
9 |
Correct |
106 ms |
5992 KB |
Output is correct |
10 |
Correct |
102 ms |
6052 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
2 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
29 ms |
4076 KB |
Output is correct |
10 |
Correct |
36 ms |
4972 KB |
Output is correct |
11 |
Correct |
35 ms |
4972 KB |
Output is correct |
12 |
Correct |
48 ms |
5248 KB |
Output is correct |
13 |
Correct |
38 ms |
5356 KB |
Output is correct |
14 |
Correct |
35 ms |
4608 KB |
Output is correct |
15 |
Correct |
98 ms |
9196 KB |
Output is correct |
16 |
Correct |
98 ms |
8988 KB |
Output is correct |
17 |
Correct |
112 ms |
9440 KB |
Output is correct |
18 |
Correct |
111 ms |
9456 KB |
Output is correct |
19 |
Correct |
97 ms |
6160 KB |
Output is correct |
20 |
Correct |
101 ms |
6312 KB |
Output is correct |
21 |
Correct |
119 ms |
6412 KB |
Output is correct |
22 |
Correct |
102 ms |
6108 KB |
Output is correct |
23 |
Correct |
100 ms |
6376 KB |
Output is correct |
24 |
Correct |
125 ms |
6024 KB |
Output is correct |
25 |
Correct |
106 ms |
5992 KB |
Output is correct |
26 |
Correct |
102 ms |
6052 KB |
Output is correct |
27 |
Incorrect |
2 ms |
364 KB |
Output isn't correct |
28 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |