# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1027457 |
2024-07-19T06:42:11 Z |
anHiep |
Sure Bet (CEOI17_sure) |
C++14 |
|
94 ms |
9300 KB |
#include<bits/stdc++.h>
#ifdef LOCAL
#include "D:\debug.h"
#else
#define cebug(...) "Orz_chUoNgnn_khanhtb_0x2ee08"
#endif
using namespace std;
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>
#define cd complex<double>
#define ld long double
const ll mod = 1e9 + 7;
const ll INF = 1e18L + 5;
const double PI = acos(-1);
const int block = 320;
const int N = 2e5;
int tc, tt = 1;
int n;
ld a[N + 5], b[N + 5];
ld f[N + 5];
ld eps = 0.000000001;
void solve() {
cin>>n;
for(int i=1; i<=n; i++) cin>>a[i]>>b[i];
ld ans = 0;
sort(a + 1, a + 1 + n, greater<ld>());
sort(b + 1, b + 1 + n, greater<ld>());
for(int l=1; l<=2; l++) {
for(int i=1; i<=n; i++) f[i] = f[i - 1] + b[i];
ld sum = 0;
for(int i=1; i<=n; i++) {
sum += a[i];
ld mi = 1e9;
int l = 1, r = n;
while(l <= r) {
int mid = (l + r)/2;
if(f[mid] - sum >= 0.0) {
mi = mid;
r = mid - 1;
}
else l = mid + 1;
}
ans = max(ans, sum - i - mi);
}
for(int i=1; i<=n; i++) swap(a[i], b[i]);
}
cout<<fixed<<setprecision(4)<<ans;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
for(tc=1; tc<=tt; tc++) solve();
cerr<<"\nTime elapsed: "<<1000.0*clock()/CLOCKS_PER_SEC<<" ms.\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4560 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4560 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
2 ms |
4572 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4568 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
2572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4560 KB |
Output is correct |
6 |
Correct |
1 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
4444 KB |
Output is correct |
11 |
Correct |
1 ms |
4444 KB |
Output is correct |
12 |
Correct |
2 ms |
4572 KB |
Output is correct |
13 |
Correct |
1 ms |
4444 KB |
Output is correct |
14 |
Correct |
1 ms |
4568 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
2572 KB |
Output is correct |
17 |
Correct |
88 ms |
8764 KB |
Output is correct |
18 |
Correct |
85 ms |
8960 KB |
Output is correct |
19 |
Correct |
89 ms |
7908 KB |
Output is correct |
20 |
Correct |
87 ms |
8784 KB |
Output is correct |
21 |
Correct |
87 ms |
8432 KB |
Output is correct |
22 |
Correct |
87 ms |
7556 KB |
Output is correct |
23 |
Correct |
88 ms |
8964 KB |
Output is correct |
24 |
Correct |
94 ms |
8956 KB |
Output is correct |
25 |
Correct |
88 ms |
7528 KB |
Output is correct |
26 |
Correct |
94 ms |
9300 KB |
Output is correct |