Submission #108831

#TimeUsernameProblemLanguageResultExecution timeMemory
108831fjzzq2002Sure Bet (CEOI17_sure)C++14
100 / 100
235 ms5112 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...