이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define pb push_back
const long long INF=1e17,N=2e5+6;
main(){
int n;cin>>n;
vector<long double> a(n),b(n);
for(int i=0;i<n;i++)
cin>>a[i]>>b[i];
sort(a.rbegin(),a.rend());
sort(b.rbegin(),b.rend());
long double ans=0,A=0,B=0;
int l=1,r=1;
A+=a[0],B+=b[0];
ans=min(A-2,B-2);
while(l<n || r<n){
if(l<n && r<n){
if(A<B)
A+=a[l++];
else
B+=b[r++];
}
else if(l<n)
A+=a[l++];
else
B+=b[r++];
ans=max(ans,min(A-l-r,B-l-r));
}
cout<<fixed<<setprecision(6)<<ans<<endl;
}
/*
5 1
lkjhg
polir
*/
컴파일 시 표준 에러 (stderr) 메시지
sure.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main(){
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |