답안 #303045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
303045 2020-09-19T19:25:46 Z Kenzo_1114 Sure Bet (CEOI17_sure) C++17
100 / 100
73 ms 1912 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100010;

int n;
double a[MAXN], b[MAXN];
double ans = 0.0000, sa = 0.0000, sb = 0.0000;

int main ()
{
	scanf("%d", &n);

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

	sort(a, a + n);	reverse(a, a + n);	
	sort(b, b + n);	reverse(b, b + n);

	int ida = 0, idb = 0;
	for(int i = 0; i < 2 * n; i++)
	{
		if(sa >= sb && idb < n)		sb += b[idb], idb++;
		else if(sa < sb && ida < n)	sa += a[ida], ida++;

		ans = max(ans, min(sa, sb) - i - 1);
	}

	printf("%.4lf\n", (double) ans);
}

/*
	
4
1.4 3.7
1.2 2
1.6 1.4 
1.9 1.5

*/

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:11:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
sure.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |   scanf("%lf %lf", &a[i], &b[i]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 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 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 0 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 0 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 1 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 68 ms 1912 KB Output is correct
18 Correct 70 ms 1912 KB Output is correct
19 Correct 68 ms 1912 KB Output is correct
20 Correct 68 ms 1912 KB Output is correct
21 Correct 72 ms 1912 KB Output is correct
22 Correct 70 ms 1876 KB Output is correct
23 Correct 68 ms 1912 KB Output is correct
24 Correct 68 ms 1912 KB Output is correct
25 Correct 68 ms 1912 KB Output is correct
26 Correct 73 ms 1912 KB Output is correct