답안 #303929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
303929 2020-09-20T19:23:57 Z peuch Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 100010;

int n;
double a[MAXN], b[MAXN];
double bWin, aWin, cost;
double ans;

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
		scanf("%lf %lf", &a[i], &b[i]);
	sort(a + 1, a + 1 + n);
	sort(b + 1, b + 1 + n);
	int aID = n, bID = n;
	while(aID > 0 && bID > 0){
		cost--;
		if(aWin < bWin || (aWin == bWin && a[aID] > b[bID]))
			aWin += a[aID--];
		else
			bWin += b[bID--];
		ans = max(ans, min(aWin, bWin) + cost);
	}
	printf("%0.4lf", ans);
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  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 384 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -