Submission #108763

# Submission time Handle Problem Language Result Execution time Memory
108763 2019-05-01T15:57:27 Z MAMBA Sure Bet (CEOI17_sure) C++17
100 / 100
126 ms 3672 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(i , j , k) for(int i = j; i < k; i++)
#define pb push_back

typedef long long ll;
typedef pair<int , int> pii;
typedef vector<int> vi;

template<typename S, typename T> 
inline bool smin(S &l, T r) { return l < r ? 0 : (l = r, 1); }
template<typename S, typename T> 
inline bool smax(S &l, T r) { return r < l ? 0 : (l = r, 1); }


constexpr int N = 1e5 + 10;

int n, l, r;
double A, B, a[N], b[N], res;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	cin >> n;
	rep(i , 0 , n) 
		cin >> a[i] >> b[i];

	sort(a , a + n, greater<double>());
	sort(b , b + n, greater<double>());

	while (l < n || r < n) {
		if ((A < B && l < n) || r == n) 
			A += a[l++];
		else 
			B += b[r++];
		A--;
		B--;
		smax(res , min(A , B));
	}

	cout << fixed << setprecision(4) << res << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 428 KB Output is correct
10 Correct 2 ms 356 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 428 KB Output is correct
10 Correct 2 ms 356 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 83 ms 3296 KB Output is correct
18 Correct 90 ms 3320 KB Output is correct
19 Correct 94 ms 3292 KB Output is correct
20 Correct 87 ms 3364 KB Output is correct
21 Correct 107 ms 3672 KB Output is correct
22 Correct 83 ms 3192 KB Output is correct
23 Correct 94 ms 3324 KB Output is correct
24 Correct 89 ms 3320 KB Output is correct
25 Correct 123 ms 3320 KB Output is correct
26 Correct 126 ms 3596 KB Output is correct