이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include "icc.h"
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define all(a) a.begin(), a.end()
using namespace std;
#define mn 2010
#define pa pair<ll, ll>
#define ld long double
ld a[mn], b[mn];
ld min(ld a, ld b){return (a<b) ? a:b;}
ld max(ld a, ld b){return (a>b) ? a:b;}
int main(){
ll n;cin >> n;
loop(i, 1, n+1) cin >> a[i]>>b[i];
sort(a+1, a+n+1, greater<ld> ()); loop(i, 1, n+1) a[i]+=a[i-1];
sort(b+1, b+n+1, greater<ld> ()); loop(i, 1, n+1) b[i]+=b[i-1];
ld ans=0.0;
ll j=0;
loop(i, 0, n+1){
while(j<n and min(a[i], b[j])-(ld)i-(ld)j<=min(a[i], b[j+1])-(ld)i-(ld)j-(ld)1) j++;
ans=max(ans, min(a[i], b[j])-(ld)i-(ld)j);
}
cout << fixed << setprecision(4)<<ans<<endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |