#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define OK cout << "OK" << endl;
const int N = 1e5+7;
vector <pii> graph[N];
int mx;
multiset <int> st;
bool less3 = 1, less2 = 0;
void init(int n, int m, vector<int> U, vector<int> V, vector<int> W) {
for (int i = 0; i < m; i++) {
graph[U[i]].pb(mp(V[i], W[i]));
graph[V[i]].pb(mp(U[i], W[i]));
}
for (int i = 0; i < n; i++) {
sort(all(graph[i]));
if (sz(graph[i]) > 2) less3 = 0;
}
for (auto to : W) st.insert(to);
if (less3) {
for (int i = 0; i < n; i++) {
if (sz(graph[i]) == 1) less2 = 1;
}
if (!less2) mx = *max_element(all(W));
}
}
int getMinimumFuelCapacity(int X, int Y) {
if (less3) {
if (less2) return -1;
return mx;
}
else {
if (!X || !Y) {
int a = (*lb(all(graph[0]), mp(max(X, Y), 0))).second;
st.erase(st.find(a));
int b = *st.begin();
st.erase(st.begin());
int c = *st.begin();
st.insert(a); st.insert(b);
return max({a, b, c});
}
else {
int a = (*lb(all(graph[0]), mp(X, 0))).second, b = (*lb(all(graph[0]), mp(Y, 0))).second;
st.erase(st.find(a));
st.erase(st.find(b));
int c = *st.begin();
st.insert(a);
st.insert(b);
return max(c, max(a, b));
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2668 KB |
Output is correct |
2 |
Correct |
3 ms |
2668 KB |
Output is correct |
3 |
Correct |
3 ms |
2668 KB |
Output is correct |
4 |
Correct |
3 ms |
2668 KB |
Output is correct |
5 |
Correct |
3 ms |
2796 KB |
Output is correct |
6 |
Correct |
3 ms |
2796 KB |
Output is correct |
7 |
Correct |
4 ms |
2736 KB |
Output is correct |
8 |
Correct |
3 ms |
2796 KB |
Output is correct |
9 |
Correct |
72 ms |
12268 KB |
Output is correct |
10 |
Correct |
122 ms |
14444 KB |
Output is correct |
11 |
Correct |
101 ms |
14336 KB |
Output is correct |
12 |
Correct |
95 ms |
14956 KB |
Output is correct |
13 |
Correct |
97 ms |
14908 KB |
Output is correct |
14 |
Correct |
79 ms |
12652 KB |
Output is correct |
15 |
Correct |
166 ms |
18808 KB |
Output is correct |
16 |
Correct |
158 ms |
18328 KB |
Output is correct |
17 |
Correct |
171 ms |
19028 KB |
Output is correct |
18 |
Correct |
173 ms |
19152 KB |
Output is correct |
19 |
Correct |
72 ms |
9708 KB |
Output is correct |
20 |
Correct |
161 ms |
19692 KB |
Output is correct |
21 |
Correct |
171 ms |
19748 KB |
Output is correct |
22 |
Correct |
176 ms |
20436 KB |
Output is correct |
23 |
Correct |
179 ms |
20432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2668 KB |
Output is correct |
2 |
Correct |
3 ms |
2668 KB |
Output is correct |
3 |
Correct |
501 ms |
19972 KB |
Output is correct |
4 |
Correct |
506 ms |
20424 KB |
Output is correct |
5 |
Correct |
524 ms |
20472 KB |
Output is correct |
6 |
Correct |
492 ms |
20212 KB |
Output is correct |
7 |
Correct |
500 ms |
20576 KB |
Output is correct |
8 |
Correct |
463 ms |
19856 KB |
Output is correct |
9 |
Correct |
480 ms |
20192 KB |
Output is correct |
10 |
Correct |
459 ms |
19868 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2668 KB |
Output is correct |
2 |
Correct |
3 ms |
2668 KB |
Output is correct |
3 |
Correct |
3 ms |
2668 KB |
Output is correct |
4 |
Correct |
3 ms |
2668 KB |
Output is correct |
5 |
Correct |
3 ms |
2796 KB |
Output is correct |
6 |
Correct |
3 ms |
2796 KB |
Output is correct |
7 |
Correct |
4 ms |
2736 KB |
Output is correct |
8 |
Correct |
3 ms |
2796 KB |
Output is correct |
9 |
Runtime error |
6 ms |
5228 KB |
Execution killed with signal 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
5228 KB |
Execution killed with signal 6 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2668 KB |
Output is correct |
2 |
Correct |
3 ms |
2668 KB |
Output is correct |
3 |
Correct |
3 ms |
2668 KB |
Output is correct |
4 |
Correct |
3 ms |
2668 KB |
Output is correct |
5 |
Correct |
3 ms |
2796 KB |
Output is correct |
6 |
Correct |
3 ms |
2796 KB |
Output is correct |
7 |
Correct |
4 ms |
2736 KB |
Output is correct |
8 |
Correct |
3 ms |
2796 KB |
Output is correct |
9 |
Correct |
72 ms |
12268 KB |
Output is correct |
10 |
Correct |
122 ms |
14444 KB |
Output is correct |
11 |
Correct |
101 ms |
14336 KB |
Output is correct |
12 |
Correct |
95 ms |
14956 KB |
Output is correct |
13 |
Correct |
97 ms |
14908 KB |
Output is correct |
14 |
Correct |
79 ms |
12652 KB |
Output is correct |
15 |
Correct |
166 ms |
18808 KB |
Output is correct |
16 |
Correct |
158 ms |
18328 KB |
Output is correct |
17 |
Correct |
171 ms |
19028 KB |
Output is correct |
18 |
Correct |
173 ms |
19152 KB |
Output is correct |
19 |
Correct |
501 ms |
19972 KB |
Output is correct |
20 |
Correct |
506 ms |
20424 KB |
Output is correct |
21 |
Correct |
524 ms |
20472 KB |
Output is correct |
22 |
Correct |
492 ms |
20212 KB |
Output is correct |
23 |
Correct |
500 ms |
20576 KB |
Output is correct |
24 |
Correct |
463 ms |
19856 KB |
Output is correct |
25 |
Correct |
480 ms |
20192 KB |
Output is correct |
26 |
Correct |
459 ms |
19868 KB |
Output is correct |
27 |
Runtime error |
7 ms |
5484 KB |
Execution killed with signal 6 |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
5228 KB |
Execution killed with signal 6 |