Submission #878643

#TimeUsernameProblemLanguageResultExecution timeMemory
878643Muhammad_AneeqSure Bet (CEOI17_sure)C++17
0 / 100
0 ms456 KiB
/* بسم الله الرحمن الرحيم Author: (:Muhammad Aneeq:) */ #pragma GCC optimize("O2") #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") #include <iostream> #include <algorithm> #include <vector> using namespace std; #define ld long double inline void solve() { int n; cin>>n; ld a[n],b[n]; for (int i=0;i<n;i++) cin>>a[i]>>b[i]; sort(a,a+n); sort(b,b+n); reverse(b,b+n); reverse(a,a+n); ld ans=0; int i=0,j=0; ld sa=0,sb=0; while (i<n||j<n) { if (i==n||sa>sb) sb+=b[j++]; else sa+=a[i++]; ans=max(ans,min(sb-(i+j),sa-(i+j))); } printf("%.4lf\n",(double)ans); } int main() { ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...