이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define pb push_back
const int maxn5 = 1e6 + 10;
vector <double> av[2];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n; cin >> n;
for(int i = 0; i < n; i++){
double a, b; cin >> a >> b;
av[0].pb(a);
av[1].pb(b);
}
sort(all(av[0])); reverse(all(av[0]));
sort(all(av[1])); reverse(all(av[1]));
for(int i = 1; i < n; i++){
av[0][i] += av[0][i - 1];
av[1][i] += av[1][i - 1];
}
double ans = 0;
for(int i = 0; i < n; i++){
int pt = lower_bound(all(av[0]), av[1][i]) - av[0].begin();
if(pt < n)
ans = max(ans, av[1][i] - i - pt - 2);
pt = lower_bound(all(av[1]), av[0][i]) - av[1].begin();
if(pt < n)
ans = max(ans, av[0][i] - i - pt - 2);
}
cout << setprecision(4) << fixed << ans << endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |