Submission #842596

# Submission time Handle Problem Language Result Execution time Memory
842596 2023-09-03T05:24:02 Z vjudge1 Sure Bet (CEOI17_sure) C++17
100 / 100
76 ms 11476 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e6 + 5;

double pre_a[N];
double pre_b[N];
double a[N] , b[N] , mx[N];

main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	if(fopen("solve.inp" , "r")) {
		freopen("solve.inp" , "r" , stdin);
		freopen("solve.out" , "w" , stdout);
	}
	int n;
	cin >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a , a + n , greater <double> ());
	sort(b , b + n , greater <double> ());
	for(int i = 1; i <= n; i++) {
		pre_a[i] = pre_a[i - 1] + a[i - 1] - 1;
		pre_b[i] = pre_b[i - 1] + b[i - 1] - 1;
	}
	for(int i = 1; i <= n; i++) {
		mx[i] = max(mx[i - 1] , pre_b[i]);
	}
	double l = 0.0;
	double r = INT_MAX;
	for(int i = 0; i < 100; i++) {
		double mid = (l + r) / 2;
		bool check = false;
		for(int j = 0; j <= n; j++) {
			int x = min(n * 1.0 , (pre_a[j] - mid));
			if(x >= 0 && mx[x] >= j + mid) {
				check = (check | x);
			}
		}
		if(check == true) l = mid;
		else r = mid;
	}
	cout << setprecision(4) << fixed << r << '\n';
	return 0x0;
}

Compilation message

sure.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main() {
      | ^~~~
sure.cpp: In function 'int main()':
sure.cpp:14:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   freopen("solve.inp" , "r" , stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:15:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   freopen("solve.out" , "w" , stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4440 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 1 ms 4440 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4580 KB Output is correct
16 Correct 1 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4440 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4440 KB Output is correct
5 Correct 1 ms 4440 KB Output is correct
6 Correct 1 ms 4440 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4440 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 1 ms 4440 KB Output is correct
13 Correct 1 ms 4440 KB Output is correct
14 Correct 1 ms 4444 KB Output is correct
15 Correct 2 ms 4580 KB Output is correct
16 Correct 1 ms 4696 KB Output is correct
17 Correct 72 ms 11344 KB Output is correct
18 Correct 73 ms 11328 KB Output is correct
19 Correct 76 ms 11476 KB Output is correct
20 Correct 70 ms 11344 KB Output is correct
21 Correct 71 ms 11200 KB Output is correct
22 Correct 71 ms 11180 KB Output is correct
23 Correct 73 ms 11344 KB Output is correct
24 Correct 71 ms 11184 KB Output is correct
25 Correct 71 ms 11344 KB Output is correct
26 Correct 71 ms 11344 KB Output is correct