Submission #199666

# Submission time Handle Problem Language Result Execution time Memory
199666 2020-02-02T15:26:50 Z algorithm16 Sure Bet (CEOI17_sure) C++14
60 / 100
188 ms 5344 KB
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
vector <double> a;
vector <double> b;
int main()
{
	int n;
	cin >> n;
	double maxi=0;
	for(int i=0;i<n;i++) {
		double x,y;
		cin >> x >> y;
		a.push_back(x);
		b.push_back(y);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	int inda=n-2,indb=n-2;
	double suma=a[n-1],sumb=b[n-1];
	for(int i=2;i<=n*2;i++) {
		maxi=max(maxi,min(suma,sumb)-i);
		if(suma<sumb && inda>=0) {
			suma+=a[inda];
			inda-=1;
		}
		else {
			sumb+=b[indb];
			indb-=1;
		}
	}
	printf("%.4lf",maxi);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 368 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 368 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 6 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 7 ms 252 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 8 ms 380 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 368 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 256 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Correct 6 ms 256 KB Output is correct
11 Correct 5 ms 256 KB Output is correct
12 Correct 7 ms 376 KB Output is correct
13 Correct 7 ms 252 KB Output is correct
14 Correct 7 ms 376 KB Output is correct
15 Correct 8 ms 380 KB Output is correct
16 Correct 7 ms 376 KB Output is correct
17 Correct 181 ms 3436 KB Output is correct
18 Correct 188 ms 3424 KB Output is correct
19 Runtime error 186 ms 5344 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Halted 0 ms 0 KB -