#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<double> a(n),b(n);
for(int i=0;i<n;i++) cin>>a[i]>>b[i];
double answer=0;
vector<int> A,B;
double curA=0,num=0;
for(int i=0;i<n;i++){
if(a[i]<1&&b[i]<1){}
else{
A.push_back(i);
B.push_back(i);
}
}
sort(A.begin(),A.end(),[&](int i,int j){
if(a[i]==a[j]) return b[i]>b[j];
return a[i]>a[j];
});
sort(B.begin(),B.end(),[&](int i,int j){
if(b[i]==b[j]) return a[i]>a[j];
return b[i]>b[j];
});
for(int&i:A){
++num;
curA+=a[i];
double curB=0;
for(int&j:B){
curB+=b[j];
++num;
answer=max(answer,min(curB,curA)-num);
}
num-=B.size();
}
cout<<answer;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |