Submission #57222

# Submission time Handle Problem Language Result Execution time Memory
57222 2018-07-14T09:50:08 Z mraron Sure Bet (CEOI17_sure) C++14
100 / 100
132 ms 16856 KB
/*
ID: noszaly1
TASK: {TASK}
LANG: C++11               
*/

//Noszály Áron 10o Debreceni Fazekas Mihály Gimnázium

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

int main() {
	IO;
	int n;
	cin>>n;
	vector<double> a,b;
	for(int i=0;i<n;++i) {
		double x,y;cin>>x>>y;
		a.pb(x);
		b.pb(y);
	}
	sort(all(a));
	sort(all(b));
	reverse(all(a));
	reverse(all(b));
	
	int L=-1, R=-1;
	double s1=0,s2=0;
	double ans=0.0;
	while(L<n || R<n) {
		//cerr<<L<<" "<<R<<" "<<s1<<" "<<s2<<"\n";
		if((s1<s2 && L<n) || (R==n)) {
			s1+=a[++L]-1;
			s2-=1;
			ans=max(ans, min(s1, s2));
		}else {
			s2+=b[++R]-1;
			s1-=1;
			ans=max(ans, min(s1, s2));
		}
	}
	
	cout<<fixed<<setprecision(4)<<ans<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 4 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 4 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 4 ms 492 KB Output is correct
8 Correct 3 ms 744 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 3 ms 756 KB Output is correct
12 Correct 4 ms 756 KB Output is correct
13 Correct 5 ms 756 KB Output is correct
14 Correct 4 ms 756 KB Output is correct
15 Correct 4 ms 756 KB Output is correct
16 Correct 6 ms 756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
4 Correct 2 ms 492 KB Output is correct
5 Correct 4 ms 492 KB Output is correct
6 Correct 2 ms 492 KB Output is correct
7 Correct 4 ms 492 KB Output is correct
8 Correct 3 ms 744 KB Output is correct
9 Correct 2 ms 744 KB Output is correct
10 Correct 3 ms 744 KB Output is correct
11 Correct 3 ms 756 KB Output is correct
12 Correct 4 ms 756 KB Output is correct
13 Correct 5 ms 756 KB Output is correct
14 Correct 4 ms 756 KB Output is correct
15 Correct 4 ms 756 KB Output is correct
16 Correct 6 ms 756 KB Output is correct
17 Correct 132 ms 3892 KB Output is correct
18 Correct 123 ms 5256 KB Output is correct
19 Correct 123 ms 6612 KB Output is correct
20 Correct 111 ms 8020 KB Output is correct
21 Correct 116 ms 9932 KB Output is correct
22 Correct 118 ms 11088 KB Output is correct
23 Correct 106 ms 12460 KB Output is correct
24 Correct 117 ms 13764 KB Output is correct
25 Correct 122 ms 15108 KB Output is correct
26 Correct 125 ms 16856 KB Output is correct