이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=1e3+7;
ld tmpA, tmpB, ans, a[N], b[N], PreA[N], PreB[N];
ll tmp, n;
bool maximize(ld &a, ld b){
if (a<b){
a=b;
return 1;
} else return 0;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i]>>b[i];
sort(a+1, a+1+n, greater<ld>());
sort(b+1, b+1+n, greater<ld>());
for (int i=1;i<=n;i++){
PreA[i]=PreA[i-1]+a[i];
PreB[i]=PreB[i-1]+b[i];
}
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++){
tmp=i+j; tmpA=PreA[i]-tmp; tmpB=PreB[j]-tmp;
maximize(ans, min(tmpA, tmpB));
}
cout<<fixed<<setprecision(4)<<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... |