Submission #878645

#TimeUsernameProblemLanguageResultExecution timeMemory
878645Muhammad_AneeqSure Bet (CEOI17_sure)C++17
0 / 100
0 ms348 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; vector<ld>a,b; for (int i=0;i<n;i++) { ld x,y; cin>>x>>y; a.push_back(x); b.push_back(y); } sort(a.begin(), a.end()); reverse(a.begin(), a.end()); sort(b.begin(), b.end()); reverse(b.begin(), b.end()); 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...