Submission #1248421

#TimeUsernameProblemLanguageResultExecution timeMemory
1248421JovicaSure Bet (CEOI17_sure)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h> using namespace std; int const maxn = 1e5+1; vector<double> A,B; int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); int n; cin>>n; for (int i=0;i<n;i++){ double a,b; cin>>a>>b; A.push_back(a);B.push_back(b); } sort(A.begin(),A.end());sort(B.begin(),B.end());reverse(A.begin(),A.end());reverse(B.begin(),B.end()); int p1 = 0,p2 = 0; double odg = 0.0,an1 = 0.0,an2 = 0.0; while (p1<n || p2<n) { if (p1 == n || an2<=an1){ an2 += B[p2]; p2++; } else if (p2 == n || an1<=an2){ an1 += A[p1]; p1++; } double k = p1+p2; odg = max(odg, min(an1,an2)-k); //cout<<"p1 = "<<p1<<" p2 = "<<p2<<endl; } printf("%.4lf",(double)odg); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...