이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll N=1e5+5;
const ll MOD=1e9+7;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
ll n;
ld a,b,ans;
priority_queue<ld> pqa,pqb;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n;
REP1(i,n){
cin>>a>>b;
pqa.push(a);pqb.push(b);
}
a=b=0;
REP1(i,2*n){
if(pqa.empty()||pqb.empty()){
if(!pqa.empty()){
a+=pqa.top();pqa.pop();
}else{
b+=pqb.top();pqb.pop();
}
}else{
if(a<=b){
a+=pqa.top();pqa.pop();
}else{
b+=pqb.top();pqb.pop();
}
}
ans=max(ans,min(a,b)-i);
}
cout<<fixed<<setprecision(4)<<ans<<"\n";
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |