# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
865587 |
2023-10-24T11:26:17 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
1 ms |
4444 KB |
#include <bits/stdc++.h>
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define optimus_prime ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fxd(x) fixed << setprecision(x)
#define all(a) (a.begin() , a.end())
#define popcount(x) __builtin_popcount(x)
#define lwb lower_bound
#define upb upper_bound
#define dl long double
#define ll long long
#define pb push_back
#define sz() size()
#define F first
#define S second
using namespace std;
const ll N = 1e5+9;
ll n;
dl a[N] , b[N] , sum , ans , pref[N];
void solve(){
cin >> n;
for (int i = 1 ; i <= n ; i++)cin >> a[i] >> b[i];
sort (a+1 , a+1+n);
sort (b+1 , b+1+n);
reverse (a+1 , a+1+n);
reverse (b+1 , b+1+n);
for (int i = 1 ; i <= n ; i++)pref[i]=pref[i-1]+b[i];
for (int i = 1 ; i <= n ; i++){
sum+=a[i];
ll l=1 , r=n , res=0;
while (l<=r){
ll md=(l+r)>>1;
if (pref[md]>=sum)r=md-1 , res=md;
else l=md+1;
}
ans=max(ans , sum-i-res);
}
cout << fxd(4) << ans;
}
signed main() {
optimus_prime;
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
4444 KB |
Output is correct |
2 |
Incorrect |
1 ms |
4444 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |