# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
503394 |
2022-01-07T19:24:27 Z |
Lobo |
Sure Bet (CEOI17_sure) |
C++17 |
|
98 ms |
5388 KB |
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define maxn
void solve() {
int n;
cin >> n;
vector<dbl> a,b;
for(int i = 1; i <= n; i++) {
dbl a1, b1;
cin >> a1 >> b1;
a.pb(a1);
b.pb(b1);
}
sort(all(a),greater<dbl>());
sort(all(b),greater<dbl>());
int pa = 0;
dbl sa = 0;
int pb = 0;
dbl sb = 0;
dbl ans = 0;
while(pa != n || pb != n) {
if(pa == n) {
sb+= b[pb];
pb++;
}
else if(pb == n) {
sa+= a[pa];
pa++;
}
else if(sa < sb) {
sa+= a[pa];
pa++;
}
else {
sb+= b[pb];
pb++;
}
ans = max(ans, min(sa - (pa+pb), sb - (pa+pb)));
}
cout.setf(ios::fixed);
cout.precision(4);
cout << ans << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
//freopen("out.out", "w", stdout);
int tt = 1;
// cin >> tt;
while(tt--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
312 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
312 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
308 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
312 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
312 KB |
Output is correct |
9 |
Correct |
0 ms |
312 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
312 KB |
Output is correct |
12 |
Correct |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
2 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
324 KB |
Output is correct |
15 |
Correct |
1 ms |
324 KB |
Output is correct |
16 |
Correct |
1 ms |
528 KB |
Output is correct |
17 |
Correct |
94 ms |
5008 KB |
Output is correct |
18 |
Correct |
81 ms |
5020 KB |
Output is correct |
19 |
Correct |
83 ms |
4916 KB |
Output is correct |
20 |
Correct |
98 ms |
5072 KB |
Output is correct |
21 |
Correct |
97 ms |
5356 KB |
Output is correct |
22 |
Correct |
95 ms |
5036 KB |
Output is correct |
23 |
Correct |
81 ms |
4948 KB |
Output is correct |
24 |
Correct |
83 ms |
5036 KB |
Output is correct |
25 |
Correct |
80 ms |
5016 KB |
Output is correct |
26 |
Correct |
89 ms |
5388 KB |
Output is correct |