Submission #51703

#TimeUsernameProblemLanguageResultExecution timeMemory
51703tmwilliamlin168Sure Bet (CEOI17_sure)C++14
20 / 100
3 ms664 KiB
#include <bits/stdc++.h> using namespace std; #define getchar_unlocked getchar #define putchar_unlocked putchar inline double in() { double result=0, d=1; char ch = getchar_unlocked(); while(true) { if(ch >= '0' && ch <= '9') break; ch = getchar_unlocked(); } result = ch-'0'; while(true) { ch = getchar_unlocked(); if (ch < '0' || ch > '9') break; result = result*10 + (ch - '0'); } if(ch=='.') { while(true) { ch = getchar_unlocked(); if (ch < '0' || ch > '9') break; result += (ch - '0')/(d*=10); } } return result; } inline void out(int x) { int rev=x, c=0; if(!x) { putchar_unlocked('0'); return; } while(!(rev%10)) { ++c; rev/=10; } rev=0; while(x) { rev=rev*10+x%10; x/=10; } while(rev) { putchar_unlocked(rev%10+'0'); rev/=10; } while(c--) putchar_unlocked('0'); } const int mxN=1e5; int n; double a[mxN+1], b[mxN+1], ans, sa, sb; int main() { ios_base::sync_with_stdio(0); cin.tie(0); n=in(); for(int i=0; i<n; ++i) a[i]=in(), b[i]=in(); sort(a, a+n+1); sort(b, b+n+1); for(int i1=n, i2=n; i1>=0&&i2>=0; ) { if(sa<sb) sa+=a[i1--]; else sb+=b[i2--]; ans=max(min(sa, sb)-(n-i1)-(n-i2), ans); } ans+=0.00005; out(ans); putchar_unlocked('.'); for(int i=0; i<4; ++i) { ans*=10; putchar_unlocked((int)ans%10+'0'); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...