답안 #498382

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
498382 2021-12-25T05:52:44 Z Ierus Sure Bet (CEOI17_sure) C++17
60 / 100
5 ms 460 KB
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("unroll-loops,Ofast,O3")
#pragma GCC target("avx,avx2,fma")
#define F first
#define S second
#define sz(x) (int)x.size()
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define NFS ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0) ;
typedef long long ll;
const int E = 1e6+777;
const long long inf = 1e18+777;
const int N = 1e3+777;
const int MOD = 1e9+7;
const bool I = 1;
int n, color[N], v1[N], sum1;
double a[N], b[N];

double getslow(int len = 0, int cl = -1, double cnt = 0){
	if(len > 12) return 0.0;
	if(len > 0){
		color[len] = cl;
		if(len == max(n, 12)){
			double sum1 = 0, sum2 = 0;
			for(int i = 1; i <= n; ++i){
				if(color[i] == 1) sum1 += a[i];
				else if(color[i] == 2) sum2 += b[i];
				else if(color[i] == 3) sum1 += a[i], sum2 += b[i];
			}
			double cur = (double)min(sum1 - cnt, sum2 - cnt);
			if(cur > sum1){
				sum1 = cur;
				for(int i = 1; i <= n; ++i) v1[i] = color[i];
			}
			return cur;
		}
	}
	return max({getslow(len + 1, 0, cnt), getslow(len + 1, 1, cnt + 1), getslow(len + 1, 2, cnt + 1), getslow(len + 1, 3, cnt+2)});
}
double getfast(double res = 0.0){
	sort(a+1,a+1+n), reverse(a+1,a+1+n);
	sort(b+1,b+1+n), reverse(b+1,b+1+n);
//	cerr << "a: ";for(int i = 1; i <= n; ++i) cerr << a[i] << ' '; cerr << '\n';
//	cerr << "b: ";for(int i = 1; i <= n; ++i) cerr << b[i] << ' '; cerr << '\n';
	double sum1 = 0, sum2 = 0;
	for(int i = 1; i <= n; ++i){
		sum1 += a[i]; sum2 = 0;
		for(int j = 1; j <= n; ++j){
			sum2 += b[j];
//			cerr << i << " " << j << " sum1: " << sum1 << ' ' << sum2 << '\n';
			res = max(res, (double)min(sum1 - (i + j), sum2 - (i + j)));
		}
	}
	sum1 = 0, sum2 = 0;
	for(int i = 1; i <= n; ++i){
		sum1 += b[i]; sum2 = 0;
		for(int j = 1; j <= n; ++j){
			sum2 += a[j];
			res = max(res, (double)min(sum1 - (i + j), sum2 - (i + j)));
		}
	}
	return res;
}
int main(){
	cin >> n;
	for(int i = 1; i <= n; ++i){
		cin >> a[i] >> b[i];
	}
//	cout << fixed << setprecision(4) << getslow() << '\n';
	cout << fixed << setprecision(4) << getfast() << '\n';
};











# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 284 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 284 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 4 ms 204 KB Output is correct
13 Correct 5 ms 308 KB Output is correct
14 Correct 4 ms 204 KB Output is correct
15 Correct 5 ms 316 KB Output is correct
16 Correct 5 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 284 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 4 ms 204 KB Output is correct
13 Correct 5 ms 308 KB Output is correct
14 Correct 4 ms 204 KB Output is correct
15 Correct 5 ms 316 KB Output is correct
16 Correct 5 ms 204 KB Output is correct
17 Runtime error 4 ms 460 KB Execution killed with signal 11
18 Halted 0 ms 0 KB -