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 <bits/stdc++.h>
#include "swap.h"
using namespace std;
const int N = 100005;
int n, m, v[N];
vector <int> v2;
void init(int n1, int m1, vector<int> u1, vector<int> v1, vector<int> w1) {
for(int i = 0; i < m1; i++){
v[v1[i]] = (w1[i]);
v2.push_back(w1[i]);
}
sort(v2.begin(), v2.end());
}
int getMinimumFuelCapacity(int x, int y) {
if(m <= 2){
return -1;
}
if(x > y) swap(x,y);
int ans = (v[x]+v[y]);
bool tr = 0, tr1 = 0;
for(int i = 0; i <= 5; i++){
if((v2[i] != v[x] and v2[i] != v[y]) or (v2[i] == v[x] and ((tr == 1 and v[y] != v[x]) or (v[y] == v[x] and tr1 == 1))) or (v2[i] == v[y] and ((tr1 == 1 and v[y] != v[x]) or (v[y] == v[x] and tr == 1)))){
ans += (2*v2[i]);
break;
}
if(v2[i] == v[x]) tr = 1;
else if(v2[i] == v[y]) tr1 = 1;
}
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... |