Submission #311258

# Submission time Handle Problem Language Result Execution time Memory
311258 2020-10-09T19:34:25 Z bigg Sure Bet (CEOI17_sure) C++14
100 / 100
78 ms 3580 KB
#include<bits/stdc++.h>
using namespace std;
typedef double ll;
const int MAXN = 1e5 + 10;
ll prefa[MAXN], prefb[MAXN], a[MAXN], b[MAXN];
int n;
double cura = 0, curb = 0;
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);
	reverse(a, a + n);
	reverse(b, b + n);
	double ans = 0;
	int it1 = 0, it2 = 0;
	for(int i = 0; i < 2*n; i++){
		if(cura >= curb && it2 < n) curb += b[it2], it2++;
		else if(cura <  curb && it1 < n) cura += a[it1], it1++;
		ans = max(ans, min(cura, curb) - i - 1);
	}
	printf("%.4lf\n", ans);

}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |  scanf("%d", &n );
      |  ~~~~~^~~~~~~~~~~
sure.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |   scanf("%lf %lf", &a[i], &b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 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 2 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 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 2 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 71 ms 3192 KB Output is correct
18 Correct 71 ms 3192 KB Output is correct
19 Correct 73 ms 3192 KB Output is correct
20 Correct 73 ms 3192 KB Output is correct
21 Correct 78 ms 3576 KB Output is correct
22 Correct 70 ms 3284 KB Output is correct
23 Correct 71 ms 3192 KB Output is correct
24 Correct 71 ms 3176 KB Output is correct
25 Correct 74 ms 3324 KB Output is correct
26 Correct 74 ms 3580 KB Output is correct