Submission #98925

# Submission time Handle Problem Language Result Execution time Memory
98925 2019-02-27T12:36:23 Z arman_ferdous Sure Bet (CEOI17_sure) C++17
100 / 100
94 ms 3684 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5+10;
int n; double a[N], b[N];

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
		scanf("%lf %lf", &a[i], &b[i]);
	sort(a,a+n); sort(b,b+n);

	int p1 = n-1, p2 = n-1;
	double ans = 0, A = 0, B = 0;
	for(int i = 1; i <= (n<<1); i++) {
		if(p1 < 0) B += b[p2--];
		else if(p2 < 0) A += a[p1--];
		else if(B > A) A += a[p1--];
		else B += b[p2--];
		ans = max(ans, min(A - i, B - i));
	} printf("%.4lf\n", ans);
	return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
sure.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lf %lf", &a[i], &b[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 400 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 400 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 356 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 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 396 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 316 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 400 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 336 KB Output is correct
6 Correct 3 ms 356 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 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 396 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 3 ms 316 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 74 ms 3300 KB Output is correct
18 Correct 77 ms 3276 KB Output is correct
19 Correct 94 ms 3240 KB Output is correct
20 Correct 94 ms 3320 KB Output is correct
21 Correct 78 ms 3684 KB Output is correct
22 Correct 82 ms 3312 KB Output is correct
23 Correct 86 ms 3320 KB Output is correct
24 Correct 82 ms 3320 KB Output is correct
25 Correct 83 ms 3320 KB Output is correct
26 Correct 71 ms 3576 KB Output is correct