Submission #303930

#TimeUsernameProblemLanguageResultExecution timeMemory
303930peuchSure Bet (CEOI17_sure)C++17
100 / 100
74 ms3576 KiB
#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);
	}
	while(aID > 0){
		cost--;
		aWin += a[aID--];
		ans = max(ans, min(aWin, bWin) + cost);
	}
	while(bID > 0){
		cost--;
		bWin += b[bID--];
		ans = max(ans, min(aWin, bWin) + cost);
	}
	printf("%0.4lf", ans);
}

Compilation message (stderr)

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]);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...