이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/// 1n the name of GOD
#include <bits/stdc++.h>
using namespace std;
#define ko exit(0);
#define nl '\n'
#define ios ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define oll(s, n, c) (s) + (c), s + (n) + c
#define pb push_back
#define bb begin()
#define ee end()
#define ff first
#define ss second
#define pii pair<int, int>
//#define for(i, l, r) for(int (i) = (l); i <= (r); ++i)
typedef long long ll;
typedef double db;
const int N = 1e5 + 777;
const int M = INT_MAX;
int n;
double a[N], b[N];
double c[N];
int main(){
ios
cin >> n;
for(int i = 1; i <= n; ++i){
cin >> a[i] >> b[i];
}
sort(oll(a, n, 1));
sort(oll(b, n, 1));
reverse(oll(a, n, 1));
reverse(oll(b, n, 1));
for(int i = 1; i <= n; ++i){
c[i] = c[i - 1] + a[i];
}
double ans = 0;
for(int i = 1; i <= n; ++i){
int q = i;
double w = 0;
for(int j = 1; j <= n; ++j){
q++;
w += b[j];
if(c[i] - (double) q <= (double)0 && w - (double) q <= (double)0 ){
break;
}
ans = max(ans, min(c[i] - (double)q, w - (double)q));
}
}
cout << fixed << setprecision(5) << (double)ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |