# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1026994 | vjudge1 | Sure Bet (CEOI17_sure) | C++14 | 74 ms | 3564 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define name "aaaaaa"
using ll = long long;
using pii = pair<int, int>;
using ld = long double;
void file(){
ios_base::sync_with_stdio(0); cin.tie(0);
if(fopen(name".inp", "r")) {
freopen(name".inp", "r", stdin);
freopen(name".out", "w", stdout);
}
}
const int maxn = 1e5 + 5;
ld a[maxn], b[maxn];
void solve (){
int n; 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);
ld suma = 0, sumb = 0, ans = 0;
int p1 = n, p2 = n;
while(1){
if(p1 == -1 || p2 == -1) break;
if(suma < sumb){
suma += a[p1];
p1--;
}else{
sumb += b[p2];
p2--;
}
ans = max(ans, min(suma, sumb) - (n - p1) - (n - p2));
}
cout << fixed << setprecision(4) << ans;
}
int main(){
file();
solve();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |