Submission #1028363

# Submission time Handle Problem Language Result Execution time Memory
1028363 2024-07-19T17:26:12 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
94 ms 4600 KB
#include <bits/stdc++.h>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<ld,ld>
#define fi first
#define se second
#define endl "\n"
#define rep(a,b,c) for(ll a=b; a<c; a++)
#define rep2(a,b,c,d) for(ll a=b; a<c; a+=d)
#define repr(a,b,c) for(ll a=b-1; a>c-1; a--)
#define repa(a,b) for(const auto &a: b)
#define multicase() int t; cin>>t; while(t--)
#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define valid(c) cout<<(c ? "YES" : "NO")<<endl;
#define valid2(c,a,b) cout<<(c ? a : b)<<endl;
#define ll long long 
#define ld long double 
#define pq_min(a) priority_queue<a, vector<a>, greater<a>>
#define pq_max(a) priority_queue<a>
#define pb push_back

using namespace std;

int main(){
	fastIO();
	cout<<setprecision(4)<<fixed<<endl;
	int n;
	cin>>n;
	ld a[n+5]{}, b[n+5]{}, ans=0;
	int l, r, mid;
	rep(i,1,n+1) cin>>a[i]>>b[i];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	reverse(a+1,a+n+1);
	reverse(b+1,b+n+1);
	rep(i,1,n+1) a[i]+=a[i-1], b[i]+=b[i-1];
	rep(i,1,n+1){
		l=1;
		r=n;
		while(l<=r){
			mid=(l+r)>>1;
			if(b[mid]<=a[i]) l=mid+1;
			else r=mid-1;
		}
		ans=max(ans,max(min(a[i],b[l])-i-l,min(a[i],b[r])-i-r));
	}
	cout<<ans<<endl;
}
# 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 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 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 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 344 KB Output is correct
16 Correct 1 ms 468 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 1 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 344 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 344 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 94 ms 4436 KB Output is correct
18 Correct 68 ms 4600 KB Output is correct
19 Correct 70 ms 4592 KB Output is correct
20 Correct 74 ms 4596 KB Output is correct
21 Correct 76 ms 4408 KB Output is correct
22 Correct 68 ms 4596 KB Output is correct
23 Correct 70 ms 4576 KB Output is correct
24 Correct 66 ms 4432 KB Output is correct
25 Correct 66 ms 4436 KB Output is correct
26 Correct 69 ms 4600 KB Output is correct