This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "swap.h"
#include <bits/stdc++.h>
using namespace std;
using pint = pair <int, int>;
const int mxN = 100005, INF = 2e9;
pint e1 = {-1, INF}, e2 = {-1, INF}, e3 = {-1, INF};
int n, edge[mxN];
void init(int N, int M, vector<int> U, vector<int> V, vector<int> W) {
n = N;
for (int i = 0; i < N - 1; i++) edge[V[i]] = W[i];
for (int i = 1; i <= N - 1; i++){
if (edge[i] <= e1.second){
e3 = e2, e2 = e1, e1 = {i, edge[i]};
}
else if (edge[i] <= e2.second){
e3 = e2, e2 = {i, edge[i]};
}
else if (edge[i] <= e3.second){
e3 = {i, edge[i]};
}
}
}
int getMinimumFuelCapacity(int X, int Y) {
if (X == 0 || Y == 0 || n <= 3) return -1;
if (X != e1.first && Y != e1.first) return max(max(edge[X], edge[Y]), e1.second);
else if (X != e2.first && Y != e2.first) return max(max(edge[X], edge[Y]), e2.second);
else return max(max(edge[X], edge[Y]), e3.second);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |