Submission #397074

# Submission time Handle Problem Language Result Execution time Memory
397074 2021-05-01T09:43:15 Z Nicholas_Patrick Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 308 KB
#include <cstdio>
#include <queue>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector<int> a(n), b(n);
	for(int i=n; i--;){
		double x, y;
		scanf("%lf%lf", &x, &y);
		a[i]=x*10000+0.1;
		b[i]=y*10000+0.1;
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	long long ansa=0, ansb=0;
	while(not a.empty() and a.back()>=20000 and b.back()>=20000){
		ansa+=a.back()-20000;
		ansb+=b.back()-20000;
		a.pop_back();
		b.pop_back();
	}
	long long best=min(ansa, ansb);
	if(ansa>ansb){
		while(not b.empty()){
			ansa-=10000;
			ansb+=b.back()-10000;
			best=max(best, min(ansa, ansb));
			b.pop_back();
		}
	}else{
		while(not a.empty()){
			ansa+=a.back()-10000;
			ansb-=10000;
			best=max(best, min(ansa, ansb));
			a.pop_back();
		}
	}
	printf("%.4lf\n", best/10000.0);
}

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:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |   scanf("%lf%lf", &x, &y);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 1 ms 204 KB Output isn't correct
5 Halted 0 ms 0 KB -