답안 #303033

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

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

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);

//	for(int i = 0; i < n; i++)	printf("a[%d] = %.4lf\n", i, a[i]);
//	for(int i = 0; i < n; i++)	printf("b[%d] = %.4lf\n", i, b[i]);

	int ida = 0, idb = 0;
	for(int i = 0; i < 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 0 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 0 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -