This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
vector<ld> a(n), b(n);
for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
sort(a.begin(), a.end());
sort(b.begin(), b.end());
ld paid = 0;
ld currA = 0;
ld currB = 0;
ld ans = 0;
while(!((currA <= currB && a.empty()) || (currA > currB && b.empty()))){
paid++;
if(currA <= currB){
currA += a.back();
a.pop_back();
}else{
currB += b.back();
b.pop_back();
}
ans = max(ans, min(currA, currB) - paid);
}
cout << fixed << setprecision(4) << ans << "\n";
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |