이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define int long long
const int N = 2e5;
const int mod = 1e9 + 7;
signed main(){
int n; cin >> n;
vector<long double> a(n), b(n);
for(int i = 0;i < n; i++){
cin >> a[i] >> b[i];
}
long double ans = 0.0;
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
long double s = 0, s1 = 0;
int cnt = 0, i =0 ;
for(int j = 0;j < n; j++){
s1+= b[j];
cnt++;
ans = max(ans, min(s, s1) - cnt);
while(i < n && s - cnt <= s1-cnt){
s+= a[i];
i++, cnt++;
ans = max(ans, min(s, s1) - cnt);
}
}
printf("%.4lf", (double)ans);
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... |