/*raghav0307 - Raghav Gupta*/
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define fast_io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int ll
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
signed main(){
fast_io();
int n;
cin >> n;
vector<ld> a;
vector<ld> b;
for(int i = 0; i < n; i++){
ld x, y;
cin >> x >> y;
a.pb(x-1);
b.pb(y-1);
}
sort(a.begin(), a.end(), greater<>());
sort(b.begin(), b.end(), greater<>());
ld tempA = a[0] - 1;
ld tempB = b[0] - 1;
ld ans = min(tempA, tempB);
int i = 1, j = 1;
while(i < n and j < n){
if(tempA < tempB){
tempB -=1 ;
tempA += a[i];
i++;
}
else{
tempA -= 1;
tempB += b[j];
j++;
}
ans = max(ans, min(tempA, tempB));
}
while(i < n and tempA <= tempB){
tempB -=1 ;
tempA += a[i];
i++;
ans = max(ans, min(tempA, tempB));
}
while(j < n and tempB <= tempA){
tempA -=1 ;
tempB += b[j];
j++;
ans = max(ans, min(tempA, tempB));
}
cout << fixed << setprecision(4);
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |