# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
865676 |
2023-10-24T13:49:01 Z |
asdfghjk |
Sure Bet (CEOI17_sure) |
C++14 |
|
73 ms |
4980 KB |
/// tree bends in youth
/// 24 .10.2023
/// success is doing same thing in every single day!!!
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
using namespace std;
const ll N =2e5+ 5;
const ll NN =2e6 + 5;
const ll INF = -1e1;
const ll MOD = 1e9 + 7;
const ll LG = 18;
const ll k = 316;
double z[N],x[N],pl[N],pr[N];
void solve(){
int n;
cin >> n;
for(int i = 1;i <= n;i++){
cin >> z[i] >> x[i];
}
sort(z + 1,z + n + 1);
sort(x + 1,x + n + 1);
reverse(z + 1,z + n + 1);
reverse(x + 1,x + n + 1);
for(int i = 1;i <= n;i++){
pr[i] = pr[i - 1] + z[i];
pl[i] = pl[i - 1] + x[i];
}
double ans = 0;
for(int i = 1;i <= n;i++){
int l = 1,r = n;
while(l < r){
int mid = (l + r) / 2;
if(pl[mid] >= pr[i])r = mid;
else l = mid + 1;
}
double cnt = double(i) + double(l);
double res = pr[i] - cnt;
if(pl[l] < pr[i])break;
ans = max(ans,res);
}
for(int i = 1;i<=n;i++){
int l = 1,r = n;
while(l < r){
int mid = (l + r) / 2;
if(pr[mid] >= pl[i])r = mid;
else l = mid + 1;
}
double cnt = double(i)+ double(l);
double res = pl[i] - cnt;
if(pr[l] < pl[i])break;
ans = max(ans,res);
}
cout << fixed << setprecision(4) << ans;
}
main (){
ios_base::sync_with_stdio(0);
cin.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
ll abd= 1;
// cin >> abd;
for(ll i = 1;i <= abd;i++){
// cout << "Case " << i << ":\n";
solve();
}
}
Compilation message
sure.cpp:59:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
59 | main (){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2520 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2520 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2392 KB |
Output is correct |
17 |
Correct |
69 ms |
4728 KB |
Output is correct |
18 |
Correct |
69 ms |
4980 KB |
Output is correct |
19 |
Correct |
68 ms |
4692 KB |
Output is correct |
20 |
Correct |
65 ms |
4692 KB |
Output is correct |
21 |
Correct |
70 ms |
4692 KB |
Output is correct |
22 |
Correct |
68 ms |
4692 KB |
Output is correct |
23 |
Correct |
68 ms |
4576 KB |
Output is correct |
24 |
Correct |
69 ms |
4692 KB |
Output is correct |
25 |
Correct |
65 ms |
4688 KB |
Output is correct |
26 |
Correct |
73 ms |
4520 KB |
Output is correct |