結果

問題 No.2918 Divide Applicants Fairly
ユーザー miiemiie
提出日時 2024-10-08 22:13:46
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 858 bytes
コンパイル時間 3,535 ms
コンパイル使用メモリ 252,708 KB
実行使用メモリ 51,328 KB
最終ジャッジ日時 2024-10-08 22:13:56
合計ジャッジ時間 6,979 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 52 ms
9,344 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
5,248 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 3 ms
5,248 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 303 ms
27,648 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 26 ms
6,400 KB
testcase_31 WA -
testcase_32 AC 689 ms
51,200 KB
testcase_33 AC 2 ms
5,248 KB
testcase_34 AC 2 ms
5,248 KB
testcase_35 AC 2 ms
5,248 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 3 ms
5,248 KB
testcase_40 AC 2 ms
5,248 KB
testcase_41 WA -
testcase_42 AC 2 ms
5,248 KB
testcase_43 WA -
testcase_44 AC 2 ms
5,248 KB
testcase_45 WA -
testcase_46 AC 147 ms
5,248 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 2 ms
5,248 KB
testcase_51 AC 2 ms
5,248 KB
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 AC 4 ms
5,248 KB
testcase_58 WA -
testcase_59 WA -
testcase_60 AC 2 ms
5,248 KB
testcase_61 WA -
testcase_62 AC 2 ms
5,248 KB
testcase_63 AC 2 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	for(int i=0; i<n; i++){
		cin >> x[i];
	}
	vector<set<int>> a(n), b(n);
	int mid = n/2;
	for(int i=0; i<(1<<mid); i++){
		int cnt = 0;
		int score = 0;
		for(int j=0; j<mid; j++){
			if(i&(1<<j)){
				cnt++;
				score += x[j];
			}
			else{
				score -= x[j];
			}
		}
		a[cnt].insert(score);
	}
	for(int i=0; i<(1<<mid); i++){
		int cnt = 0;
		int score = 0;
		for(int j=mid; j<n; j++){
			if(i&(1<<j-mid)){
				cnt++;
				score += x[j];
			}
			else{
				score -= x[j];
			}
		}
		b[cnt].insert(score);
	}
	int ans = 1e9;
	for(int i=0; i<=mid; i++){
		for(int xx : a[i]){
			auto itr = b[mid-i].lower_bound(-xx);
			if(itr != b[mid-i].end()) ans = min(ans, xx+*itr);
			if(itr != b[mid-i].begin()) ans = min(ans, -xx-*prev(itr));
		}
	}
	cout << ans << endl;
}
0