답안 #938252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
938252 2024-03-05T03:45:04 Z vjudge1 Sure Bet (CEOI17_sure) C++17
0 / 100
0 ms 344 KB
#include "bits/stdc++.h"
 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds; 
 
using namespace std;
 
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define ordered_mset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

const int INF = 1e18;

int binpow (int a, int n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return binpow (a, n-1) * a;
	else {
		int b = binpow (a, n/2);
		return b * b;
	}
}

void solve(){	
	
	int n;
	cin >> n;
	double a[n],b[n];
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i];
	}
	double ans = 0;
	for(int mask = 0;mask < binpow(3,n);mask++){
		double sum1 = 0,sum2 = 0;
		int cnt = 0;
		for(int i = 0;i < n;i++){
			if((mask / binpow(3,i)) % 3 == 0){
				//~ cout << 0;
			} else if((mask / binpow(3,i)) % 3 == 1){
				//~ cout << 1;
				cnt++;
				sum1 += a[i];
			} else{
				//~ cout << 2;
				sum2 += b[i];
				cnt++;
			}
		}
		//~ cout << "\n";
		ans = max(ans,min(sum1 - cnt,sum2 - cnt));
	}
	cout << fixed << setprecision(4);
	cout << ans << "\n";
	
}
 
signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	
	int t = 1;
//	cin >> t;
	while(t--){
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -