#include <bits/stdc++.h>
#include "swap.h"
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=1e5+5;
int sz[N];
multiset <int> ms;
int n;
void init(int N, int M,vector<int> U,vector<int> V,vector<int> W) {
n=N;
for(int i=0;i<M;i++){
sz[V[i]]=W[i];
ms.insert(sz[V[i]]);
}
}
int getMinimumFuelCapacity(int X, int Y) {
if(n<=3)return -1;
int ans=0;
if(sz[X]!=0)ms.erase(ms.find(sz[X]));
if(sz[Y]!=0)ms.erase(ms.find(sz[Y]));
if(X==0 or Y==0 ){
ans=max({sz[X],sz[Y],*ms.begin()});
int x=*ms.begin();
ms.erase(ms.begin());
ans=max(ans,*ms.begin());
if(sz[X]!=0)ms.insert(sz[X]);
if(sz[Y]!=0)ms.insert(sz[Y]);
ms.insert(x);
}
else{
ans=max({sz[X],sz[Y],*ms.begin()});
ms.insert(sz[X]);
ms.insert(sz[Y]);
}
return ans;
}
/*signed main(){
ios_base::sync_with_stdio();
cin.tie(0);cout.tie(0);
int n,m;
cin>>n>>m;
vector <int> a(m),b(m),c(m);
for(int i=0;i<m;i++){
cin>>a[i]>>b[i]>>c[i];
}
init(n,m,a,b,c);
int q;
cin>>q;
while(q--){
int u,v;
cin>>u>>v;
cout<<getMinimumFuelCapacity(u,v)<<"\n";
}
}*/
/*
3
1 10
3 10
8 15
2
1 2
2 3
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
199 ms |
10360 KB |
Output is correct |
4 |
Correct |
199 ms |
14520 KB |
Output is correct |
5 |
Correct |
233 ms |
14564 KB |
Output is correct |
6 |
Correct |
196 ms |
14412 KB |
Output is correct |
7 |
Correct |
203 ms |
14544 KB |
Output is correct |
8 |
Correct |
205 ms |
14200 KB |
Output is correct |
9 |
Correct |
198 ms |
14292 KB |
Output is correct |
10 |
Correct |
214 ms |
14144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |