Submission #286003

# Submission time Handle Problem Language Result Execution time Memory
286003 2020-08-29T22:08:19 Z Blagojce Sure Bet (CEOI17_sure) C++11
100 / 100
266 ms 5296 KB
#include <bits/stdc++.h>
#define fr(i, n, m) for(int i = (n); i < (m); i ++)
#define pb push_back
#define st first
#define nd second
#define pq priority_queue
#define all(x) begin(x), end(x)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const ll inf = 1e18;
const ld eps = 1e-13;
const ll mod = 1e9+7; 
const int i_inf = 1e9;
const int mxn = 1e5;
mt19937 _rand(time(NULL));
clock_t timer = clock();


void solve(){
	int n;
	cin >> n;
	ld l[n], r[n];
	fr(i, 0, n){
		cin >> l[i] >> r[i];
	}
	sort(l, l+n);
	reverse(l, l+n);
	sort(r, r+n);
	reverse(r, r+n);
	
	ld ans = 0;
	ld sa = 0;
	ld sb = 0;
	int a = 0;
	int b = 0;
	fr(i, 1, 2*n+1){
		if(a == n) sb += r[b++];
		else if(b == n) sa += l[a++];
		else{
			if(sa < sb){
				sa += l[a++];
			}
			else{
				sb += r[b++];
			}
		}
		ans = max(ans, min(sa, sb) - i);
		
	}
	cout<<fixed<<setprecision(4)<<ans<<endl;
	
	
}

int main(){
	solve();
}
	
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 231 ms 4856 KB Output is correct
18 Correct 228 ms 4856 KB Output is correct
19 Correct 227 ms 4856 KB Output is correct
20 Correct 230 ms 4984 KB Output is correct
21 Correct 262 ms 5296 KB Output is correct
22 Correct 234 ms 5112 KB Output is correct
23 Correct 226 ms 4856 KB Output is correct
24 Correct 227 ms 4856 KB Output is correct
25 Correct 228 ms 4984 KB Output is correct
26 Correct 266 ms 5244 KB Output is correct