이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
double Get(vector<double> a , vector<double> b) {
int n = (int)a.size();
double h = 0 , t = 0;
double ans = 0;
int id = 0;
for (int i = 0 ; i < n ; i++) {
h += a[i];
double new_t = t - 1;
int add = 0;
while (id < n && min(h - add , new_t) < ans) {
add += 1;
new_t += b[id];
id += 1;
}
h -= add;
t = new_t;
ans = max(ans , min(h , t));
}
return ans;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<double> a(n) , b(n);
for (int i = 0 ; i < n ; i++) {
cin >> a[i] >> b[i];
a[i] -= 1;
b[i] -= 1;
}
sort(a.rbegin() , a.rend());
sort(b.rbegin() , b.rend());
double ans = max(Get(a , b) , Get(b , a));
cout << fixed << setprecision(4) << ans << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |