Submission #954487

# Submission time Handle Problem Language Result Execution time Memory
954487 2024-03-28T03:40:39 Z mocha Sure Bet (CEOI17_sure) C++14
100 / 100
94 ms 6732 KB
#include <bits/stdc++.h>
using namespace std;
const int mx = 1e5+5;

int n;
long double a[mx], b[mx];
long double ans = 0;
long double sa = 0;
long double d[mx];

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

	cin >> n;
	for (int i=0;i<n;i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a+n); reverse(a, a+n);
	sort(b, b+n); reverse(b, b+n);
	d[0] = b[0];
	for (int i=1;i<n;i++) {
		d[i] = d[i-1] + b[i];
	}
	for (int i=0;i<n;i++) {
		sa += a[i];
		if (a[i] <= 1) break;
		long double sb = 0;
	//	for (int j=0;j<n;j++) {
	//		cout << sa - i - j - 2 << " ";
	//	}
	//	cout << "\n";
		int lc = 0, rc = n-1;
		while (lc < rc) {
			int m = lc + rc >> 1;
			if ((sa - i - m - 2) < (d[m] - i - m - 2)) {
				rc = m;
			} else {
				lc = m+1;
			}
		}
	//	cout << lc << " ";
		long double tmp;
		tmp = min(sa - i - lc - 2, d[lc] - i - lc - 2);
		if ( lc != 0 ) {
			tmp = max(tmp, min(sa - i - lc - 1, d[lc-1] - i - lc - 1));
		}
		ans = max(ans, tmp);
  	}
//	cout << "\n";
	cout << fixed << setprecision(4) << ans << "\n";
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:34:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   34 |    int m = lc + rc >> 1;
      |            ~~~^~~~
sure.cpp:27:15: warning: unused variable 'sb' [-Wunused-variable]
   27 |   long double sb = 0;
      |               ^~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4440 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 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 3 ms 4444 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4572 KB Output is correct
15 Correct 5 ms 4444 KB Output is correct
16 Correct 2 ms 4444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 2 ms 4440 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 4440 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 3 ms 4444 KB Output is correct
13 Correct 2 ms 4444 KB Output is correct
14 Correct 2 ms 4572 KB Output is correct
15 Correct 5 ms 4444 KB Output is correct
16 Correct 2 ms 4444 KB Output is correct
17 Correct 91 ms 6484 KB Output is correct
18 Correct 81 ms 6472 KB Output is correct
19 Correct 79 ms 6316 KB Output is correct
20 Correct 76 ms 6512 KB Output is correct
21 Correct 82 ms 6732 KB Output is correct
22 Correct 77 ms 6484 KB Output is correct
23 Correct 80 ms 6472 KB Output is correct
24 Correct 81 ms 6484 KB Output is correct
25 Correct 76 ms 6456 KB Output is correct
26 Correct 94 ms 6704 KB Output is correct