#include "swap.h"
#include <bits/stdc++.h>
#include <vector>
using namespace std;
const int MAXN = 1e5 + 5;
int s[MAXN], w[MAXN];
int n;
void init(int N, int M, std::vector<int> U, std::vector<int> V, std::vector<int> W) {
n = N;
for (int i = 0; i < n; i++)
s[V[i]] = w[V[i]] = W[i];
sort(s, s + n);
}
#define is_best(i) w[i] == s[1]
#define is_second(i) w[i] == s[2]
int getMinimumFuelCapacity(int x, int y) {
if (n <= 3) return -1;
if (x == 0) return 2 * w[y] + 2 * s[1 + (is_best(y))] + 2 * s[2 + (is_best(y))];
int a = 1 + (is_best(x)) + (is_best(y));
if (w[x] != s[1] and w[x] == s[2]) a++;
if (w[y] != s[1] and w[y] == s[2]) a++;
return (2 * w[x]) + (2 * w[y]) + (2 * s[a]);
}
# | 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... |