#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
vector<double> v1,v2;
for(int i=0;i<n;i++) {
double a,b;
cin>>a>>b;
a-=1;
b-=1;
v1.push_back(a);
v2.push_back(b);
}
sort(v1.begin(),v1.end(),greater<double>());
sort(v2.begin(),v2.end(),greater<double>());
double s1[n],s2[n];
s1[0]=v1[0];
s2[0]=v2[0];
for(int i=1;i<n;i++) {
s1[i]=s1[i-1]+v1[i];
s2[i]=s2[i-1]+v2[i];
}
double res=0;
int ptr=0;
for(int i=0;i<n;i++) {
while(ptr+1<n && s1[i]>s2[ptr]) {
ptr++;
}
res=max(res,min(s1[i]-ptr-1,s2[ptr]-i-1));
}
cout<<fixed<<setprecision(4);
cout<<res<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Incorrect |
4 ms |
128 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Incorrect |
4 ms |
128 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Incorrect |
4 ms |
128 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |