#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
void solve(){
int n;
cin >> n;
vector<float> a(n), b(n);
for(int i = 0; i < n; i++)
cin >> a[i] >> b[i];
sort(a.begin(), a.end(), greater<float>());
sort(b.begin(), b.end(), greater<float>());
double total_a = 0, total_b = 0, total_max = 0;
for(int i = 0; i < n; i++){
total_b += b[i];
total_max = max(total_max, min(total_a - (i+1), total_b - (i+1)));
}
total_b = 0;
for(int i = 0; i < n; i++){
total_a += a[i];
total_b = 0;
total_max = max(total_max, min(total_a, total_b - (i+1)));
//cout << total_a << ' ' << -(i+1) << '\n';
for(int j = 0; j < n; j++){
total_b += b[j];
total_max = max(total_max, min(total_a - (j+i+2), total_b - (j+i+2)));
//cout << total_a - (j+i+2) << ' ' << total_b - (j+i+2) << ' ' << total_b << '\n';
}
}
cout << total_max << '\n';
}
int main(){
//freopen("flota.in", "r", stdin);
//freopen("flota.out", "w", stdout);
ios::sync_with_stdio(0); cin.tie(0);
int t = 1;
//cin >> t;
while(t--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |