이 제출은 이전 버전의 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=1e2+7;
ld a[N], b[N], n;
ll A[N], B[N];
long double ans=0;
pair <ll, ll> d[10];
void Backtrack(int i){
    for (int j=1;j<=4;j++){
        A[i]=d[j].fi;
        B[i]=d[j].se;
        if (i==n){
            ll cnt=0;
            ld tmp1=0, tmp2=0;
            for (int k=1;k<=n;k++){
                if (A[k]==1){
                    cnt++;
                    tmp1+=a[k];
                }
                if (B[k]==1){
                    cnt++;
                    tmp2+=b[k];
                }
            }
            tmp1=tmp1-cnt;
            tmp2=tmp2-cnt;
            ans=max(ans, min(tmp1, tmp2));
        } else Backtrack(i+1);
    }
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin>>n;
    d[1].fi=0; d[1].se=0;
    d[2].fi=1; d[2].se=1;
    d[3].fi=1; d[3].se=0;
    d[4].fi=0; d[4].se=1;
    for (int i=1;i<=n;i++) cin>>a[i]>>b[i];
    Backtrack(1);
    cout<<fixed<<setprecision(5)<<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... |