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 <vector>
#include<bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
int n, m;
vector<int> w;
vector<pii> c;
void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
n = N; m = M;
w.resize(n + 5);
for (int i = 0; i < m; i++) c.emplace_back(W[i], V[i]), w[V[i]] = W[i];
sort(c.begin(), c.end());
}
int getMinimumFuelCapacity(int X, int Y) {
if (X > Y) swap(X, Y);
int ans = -1;
vector<int> aux;
for (auto &[x, y]: c) {
if (y == X || y == Y) continue;
aux.emplace_back(x);
if (aux.size() == 2) break;
}
if (!X && aux.size() >= 2) ans = max(aux[1], w[Y]);
if (X && aux.size() >= 1) ans = max({aux[0], w[X], w[Y]});
return ans;
}
# | 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... |