Submission #108831

# Submission time Handle Problem Language Result Execution time Memory
108831 2019-05-02T08:58:54 Z fjzzq2002 Sure Bet (CEOI17_sure) C++14
100 / 100
235 ms 5112 KB
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n; ld a[SZ],b[SZ],sa[SZ],sb[SZ];
bool ok(ld x)
{
	int l=0,r=0;
	while(1)
	{
		if(sa[l]-l-r<x)
		{
			if(l==n) return 0; ++l;
		}
		else if(sb[r]-l-r<x)
		{
			if(r==n) return 0; ++r;
		}
		else break;
	}
	return 1;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i]>>b[i];
	sort(a+1,a+1+n,greater<ld>());
	sort(b+1,b+1+n,greater<ld>());
	for(int i=1;i<=n;++i)
		sa[i]=sa[i-1]+a[i],
		sb[i]=sb[i-1]+b[i];
	ld l=0,r=1e9;
	for(int i=1;i<=150;++i)
	{
		ld m=(l+r)/2;
		if(ok(m)) l=m; else r=m;
	}
	printf("%.4lf\n",(double)l);
}

Compilation message

sure.cpp: In function 'bool ok(ld)':
sure.cpp:42:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if(l==n) return 0; ++l;
    ^~
sure.cpp:42:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if(l==n) return 0; ++l;
                       ^~
sure.cpp:46:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if(r==n) return 0; ++r;
    ^~
sure.cpp:46:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if(r==n) return 0; ++r;
                       ^~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 412 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 412 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 412 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 161 ms 4828 KB Output is correct
18 Correct 177 ms 4964 KB Output is correct
19 Correct 199 ms 4772 KB Output is correct
20 Correct 194 ms 4828 KB Output is correct
21 Correct 216 ms 5112 KB Output is correct
22 Correct 174 ms 4856 KB Output is correct
23 Correct 178 ms 4768 KB Output is correct
24 Correct 203 ms 4784 KB Output is correct
25 Correct 231 ms 4904 KB Output is correct
26 Correct 235 ms 4948 KB Output is correct