結果

問題 No.2918 Divide Applicants Fairly
ユーザー miiemiie
提出日時 2024-10-08 22:23:50
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 929 ms / 2,000 ms
コード長 716 bytes
コンパイル時間 3,280 ms
コンパイル使用メモリ 258,272 KB
実行使用メモリ 167,296 KB
最終ジャッジ日時 2024-10-08 22:24:32
合計ジャッジ時間 30,101 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
26,804 KB
testcase_01 AC 71 ms
34,540 KB
testcase_02 AC 50 ms
30,576 KB
testcase_03 AC 680 ms
135,936 KB
testcase_04 AC 731 ms
120,412 KB
testcase_05 AC 134 ms
46,208 KB
testcase_06 AC 165 ms
50,172 KB
testcase_07 AC 62 ms
34,672 KB
testcase_08 AC 82 ms
38,420 KB
testcase_09 AC 490 ms
77,440 KB
testcase_10 AC 732 ms
155,520 KB
testcase_11 AC 687 ms
104,776 KB
testcase_12 AC 485 ms
73,532 KB
testcase_13 AC 282 ms
58,164 KB
testcase_14 AC 171 ms
50,292 KB
testcase_15 AC 677 ms
112,620 KB
testcase_16 AC 870 ms
163,380 KB
testcase_17 AC 400 ms
73,400 KB
testcase_18 AC 662 ms
104,744 KB
testcase_19 AC 48 ms
30,564 KB
testcase_20 AC 501 ms
100,872 KB
testcase_21 AC 420 ms
73,408 KB
testcase_22 AC 67 ms
34,548 KB
testcase_23 AC 497 ms
77,568 KB
testcase_24 AC 850 ms
155,468 KB
testcase_25 AC 705 ms
108,672 KB
testcase_26 AC 133 ms
46,236 KB
testcase_27 AC 560 ms
96,976 KB
testcase_28 AC 173 ms
50,284 KB
testcase_29 AC 252 ms
57,992 KB
testcase_30 AC 748 ms
128,136 KB
testcase_31 AC 277 ms
61,824 KB
testcase_32 AC 811 ms
163,384 KB
testcase_33 AC 18 ms
18,816 KB
testcase_34 AC 26 ms
22,776 KB
testcase_35 AC 36 ms
26,800 KB
testcase_36 AC 929 ms
96,896 KB
testcase_37 AC 844 ms
93,056 KB
testcase_38 AC 759 ms
89,152 KB
testcase_39 AC 59 ms
112,592 KB
testcase_40 AC 51 ms
89,152 KB
testcase_41 AC 75 ms
93,184 KB
testcase_42 AC 56 ms
97,012 KB
testcase_43 AC 54 ms
100,868 KB
testcase_44 AC 55 ms
104,784 KB
testcase_45 AC 58 ms
108,672 KB
testcase_46 AC 83 ms
167,296 KB
testcase_47 AC 87 ms
38,416 KB
testcase_48 AC 534 ms
77,440 KB
testcase_49 AC 793 ms
93,184 KB
testcase_50 AC 105 ms
42,416 KB
testcase_51 AC 570 ms
77,440 KB
testcase_52 AC 376 ms
89,148 KB
testcase_53 AC 612 ms
81,280 KB
testcase_54 AC 106 ms
81,280 KB
testcase_55 AC 650 ms
85,296 KB
testcase_56 AC 713 ms
85,244 KB
testcase_57 AC 457 ms
96,968 KB
testcase_58 AC 718 ms
85,260 KB
testcase_59 AC 666 ms
85,276 KB
testcase_60 AC 231 ms
58,036 KB
testcase_61 AC 700 ms
85,248 KB
testcase_62 AC 480 ms
73,532 KB
testcase_63 AC 513 ms
73,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	const int sz = 16000005;
	vector<bitset<sz>> dp(n+1);
	for(int i=0; i<n; i++){
		auto ndp = dp;
		for(int j=max(0, n/2-i); j<=min(n/2+i, n); j++){
			if(j != 0) ndp[j-1] |= dp[j]>>a[i];
			if(j != n) ndp[j+1] |= dp[j]<<a[i];
		}
		swap(ndp, dp);
		if(dp[n/2].test(sz/2)){
			cout << 0 << endl;
			return 0;
		}
		dp[n/2+1].set(sz/2+a[i], 1);
	}
	int ans = 1e9;
	for(int i=sz/2-800000; i<=sz/2+800000; i++){
		if(dp[n/2].test(i)) ans = min(ans, max(sz/2-i, i-sz/2));
	}
	cout << ans << endl;
}
0