# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
865383 |
2023-10-24T07:48:06 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
61 ms |
2252 KB |
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(), x.end()
#define sz(x) x.size()
#define forik(x) ll i = 1; i <= x; i++
const int mod = 1e9 + 7;
using namespace std;
ll t, n, m, c, d, e;
double a, b, sum1, sum2;
vector <double> v, q;
ll gcd (ll a, ll b){
while (a > 0 && b > 0){
if (a >= b){
a %= b;
}
else{
b %= a;
}
}
return a + b;
}
ll binpow (ll a, ll b){
a %= mod;
if (b == 0){
return 1;
}
if (b % 2 == 1){
return binpow (a, b - 1) % mod * a;
}
else{
ll t = binpow (a, b / 2) % mod;
return t * t % mod;
}
}
signed main (){
//freopen (".in", "r", stdin);
//freopen (".out", "w", stdout);
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++){
cin >> a >> b;
v.pb (a);
q.pb (b);
}
sort (all (v));
sort (all (q));
c = n - 1;
d = n - 1;
e = 0;
double ans = 0;
while (true){
if (c < 0 && d < 0){
break;
}
if (sum1 <= sum2 && c >= 0){
sum1 += v[c];
c--;
e++;
}
else if (d >= 0){
sum2 += q[d];
d--;
e++;
}
else{
sum1 += v[c];
c--;
e++;
}
// cout << sum1 << ' ' << sum2 << ' ' << e << ' ' << d << ' ' << c << '\n';
ans = max (ans, min (sum1 - e, sum2 - e));
}
cout << fixed << setprecision(4) << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
56 ms |
1996 KB |
Output is correct |
18 |
Correct |
57 ms |
2000 KB |
Output is correct |
19 |
Correct |
60 ms |
2000 KB |
Output is correct |
20 |
Correct |
57 ms |
2232 KB |
Output is correct |
21 |
Correct |
59 ms |
2232 KB |
Output is correct |
22 |
Correct |
57 ms |
2036 KB |
Output is correct |
23 |
Correct |
56 ms |
2252 KB |
Output is correct |
24 |
Correct |
56 ms |
2044 KB |
Output is correct |
25 |
Correct |
56 ms |
2000 KB |
Output is correct |
26 |
Correct |
61 ms |
1988 KB |
Output is correct |