이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define append push_back
#define add insert
#define nl '\n'
#define ff first
#define ss second
#define panic break
#define pii pair<int,int>
#define pic pair<int,char>
#define all(x) (x).begin(),(x).end()
#define sum(a) accumulate(all(a),0)
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define terminator main
#define N 2001
ld prex[N];
ld prey[N];
void solve(){
int n,l,r;
ld o,p,q;
cin>>n;
vector<ld> x,y;
for(int i=0;i<n;i++){
cin>>p>>q;
x.append(p);
y.append(q);
}
sort(all(x));
sort(all(y));
reverse(all(x));
reverse(all(y));
for(int i=o=l=r=p=q=0;i<2*n;i++){
if(p<=q){
if(l==n) break;
p+=x[l];
l++;
}
else{
if(r==n) break;
q+=y[r];
r++;
}
o=max(o,min(p,q)-i-1);
}
cout<<o;
}
int terminator(){
L0TA;
cout<<fixed<<setprecision(4);
solve();
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... |