#include <bits/stdc++.h>
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout);
#define adiyer(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define eb emplace_back
#define elif else if
#define uns unsigned
#define emp empty()
#define S second
#define F first
#define int long long
using namespace std;
typedef long long ll;
typedef long double ldb;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef pair < ll, ll > pll;
typedef pair < int, int > pi;
typedef pair < ldb, ldb > pldb;
typedef vector < pair < ll, ll > > vpll;
typedef vector < pair < int, int > > vpi;
const int N = 1e5 + 123;
const int mod = 1e9 + 7;
const int mxlg = 30;
const int P = 31;
const int K = 4;
const ll inf = 1e9 + 10;
ll n, j;
ldb x, y, res;
ldb a[N], b[N];
void output(){
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
sort(a + 1, a + n + 1);
sort(b + 1, b + n + 1), j = n;
for(int i = n; i >= 1; i--){
while(x < y && j > 0){
x += a[j--], x--, y--;
res = max(res, min(x, y));
}
y += b[i], x--, y--;
res = max(res, min(x, y));
}
cout << fixed << setprecision(4) << res;
}
const bool cases = 0;
signed main(){
// file("disrupt");
adiyer();
int tt = 1;
if(cases) cin >> tt;
for(int i = 1; i <= tt; i++){
// cout << "Case " << i << ":\n";
output();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2476 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2476 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2476 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |