Submission #872661

#TimeUsernameProblemLanguageResultExecution timeMemory
872661vjudge1Sure Bet (CEOI17_sure)C++11
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using ld = long double; int main() { int n; cin >> n; vector<ld> v1(n), v2(n); for(int i = 0; i<n; i++) { ld a, b; cin >> a >> b; v1[i] = a; v2[i] = b; } sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); reverse(v1.begin(), v1.end()); reverse(v2.begin(), v2.end()); ld ptr1 = 0, ptr2 = 0; ld val1 = 0, val2 = 0, rem = 0; ld ans = 0; /* for(int i : v1) cout << i << " "; cout << "\n"; for(int i : v2) cout << i << " "; cout << "\n"; */ while(ptr1 <= n && ptr2 <= n) { if(val1 < val2) { val1 += v1[ptr1]; ptr1++; rem += 1; } else{ val2+= v2[ptr2]; ptr2++; rem += 1; } ans = max(ans, min(val1, val2) - rem); } printf("%.4LF", ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...