#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
template <class T>
void rd(T &x) {
int sgn = 1;
char ch;
x = 0;
for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
if (ch == '-') ch = getchar(), sgn = -1;
for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
x *= sgn;
}
template <class T>
void wr(T x) {
if (x < 0) putchar('-'), wr(-x);
else if (x < 10) putchar(x + '0');
else wr(x / 10), putchar(x % 10 + '0');
}
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
void usaco(string s){
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
int n;
double ans = 0;
vector<double> A, B;
int main() {
#ifdef LOCAL_DEFINE
freopen("input.txt", "r", stdin);
#endif
cin >> n;
rep(i, 1, n+1){
double a, b;
cin >> a >> b;
A.push_back(a);
B.push_back(b);
}
sort(A.rbegin(), A.rend());
sort(B.rbegin(), B.rend());
rep(i, 1, n){ A[i] += A[i-1]; B[i] += B[i-1]; }
rep(i, 1, 2*n+1){
double l = 0, r = 1e9;
while(r - l > 1e-5){
double mid = (l + r)/1;
int pos1 = lower_bound(A.begin(), A.end(), mid) - A.begin(), pos2 = lower_bound(B.begin(), B.end(), mid) - B.begin();
if(A.back() >= mid and B.back() >= mid and pos1 + pos2 + 2 <= i) l = mid;
else r = mid;
}
ans = max(ans, l - i);
}
printf("%.4f\n", ans);
}
Compilation message
sure.cpp: In function 'void usaco(std::string)':
sure.cpp:33:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
33 | freopen((s+".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:34:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
34 | freopen((s+".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2062 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2062 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2062 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |