# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
891144 |
2023-12-22T08:43:43 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
76 ms |
8528 KB |
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
void dgb_out() { cerr << "\n"; }
template<typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) { cerr << " " << H; dgb_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file(s) freopen(s".in", "r", stdin);freopen(s".out", "w", stdout);
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ft first
#define sd second
#define ll long long
#define pll pair<ll,ll>
const int N = 5e5 + 10;
const int M = 2e7 + 5;
const int B = 316;
const ll msize = 2;
const ll mod1 = 1e9 + 7;
const ll mod2 = 998244353;
const long double Phi = acos(-1);
const long long inf = 2e9;
ll binmul(ll x, ll ti, ll m);
ll binpow(ll x, ll ti, ll m);
ll n;
long double a[N], b[N];
const void solve() {
cin >> n;
for (int i = 1; i <= n; ++ i) cin >> a[i] >> b[i];
sort(a + 1, a + n + 1); reverse(a + 1, a + n + 1);
sort(b + 1, b + n + 1); reverse(b + 1, b + n + 1);
int i = 1, j = 1;
long double ans = 0, cnt = 0, suma = 0, sumb = 0;
while (i <= n || j <= n) {
if ((j <= n && suma >= sumb) || (i == n + 1)) {
sumb += b[j ++];
} else {
suma += a[i ++];
}
++ cnt;
ans = max(ans, min(suma, sumb) - cnt);
}
cout << fixed << setprecision(4) << ans;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
srand(time(NULL));
//file("monsters");
int tt = 1;
// cin >> tt;
for (int i = 1; i <= tt; ++ i) {
solve();
}
return 0;
}
// Template functions
ll binmul(ll x, ll ti, ll m) { ll res = 0;while (ti){if(ti & 1)res += x;x += x;ti >>= 1; x %= m; res %= m;} return res;}
ll binpow(ll x, ll ti, ll m) { ll res = 1;while (ti){if(ti & 1)res=binmul(res,x,m);x=binmul(x,x,m);ti >>= 1; x %= m; res %= m;} return res;}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2516 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2516 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2560 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2516 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2560 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2524 KB |
Output is correct |
17 |
Correct |
70 ms |
8020 KB |
Output is correct |
18 |
Correct |
71 ms |
7924 KB |
Output is correct |
19 |
Correct |
73 ms |
8148 KB |
Output is correct |
20 |
Correct |
72 ms |
8024 KB |
Output is correct |
21 |
Correct |
75 ms |
8524 KB |
Output is correct |
22 |
Correct |
70 ms |
8020 KB |
Output is correct |
23 |
Correct |
71 ms |
8016 KB |
Output is correct |
24 |
Correct |
72 ms |
8320 KB |
Output is correct |
25 |
Correct |
71 ms |
8020 KB |
Output is correct |
26 |
Correct |
76 ms |
8528 KB |
Output is correct |