結果

問題 No.2918 Divide Applicants Fairly
ユーザー cled0328cled0328
提出日時 2024-10-07 17:55:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,704 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 202,876 KB
実行使用メモリ 89,388 KB
最終ジャッジ日時 2024-10-07 21:07:55
合計ジャッジ時間 33,016 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
23,728 KB
testcase_01 AC 70 ms
27,820 KB
testcase_02 AC 59 ms
25,772 KB
testcase_03 AC 1,156 ms
77,744 KB
testcase_04 AC 889 ms
70,668 KB
testcase_05 AC 121 ms
31,916 KB
testcase_06 AC 141 ms
36,012 KB
testcase_07 AC 70 ms
27,948 KB
testcase_08 AC 83 ms
27,824 KB
testcase_09 AC 352 ms
46,380 KB
testcase_10 AC 1,504 ms
85,548 KB
testcase_11 AC 662 ms
62,256 KB
testcase_12 AC 317 ms
46,512 KB
testcase_13 AC 187 ms
42,156 KB
testcase_14 AC 138 ms
36,016 KB
testcase_15 AC 766 ms
65,964 KB
testcase_16 AC 1,673 ms
89,344 KB
testcase_17 AC 312 ms
46,464 KB
testcase_18 AC 664 ms
62,080 KB
testcase_19 AC 57 ms
23,040 KB
testcase_20 AC 589 ms
58,240 KB
testcase_21 AC 328 ms
46,336 KB
testcase_22 AC 73 ms
26,880 KB
testcase_23 AC 356 ms
46,464 KB
testcase_24 AC 1,506 ms
85,504 KB
testcase_25 AC 709 ms
62,080 KB
testcase_26 AC 120 ms
30,848 KB
testcase_27 AC 557 ms
58,032 KB
testcase_28 AC 145 ms
36,016 KB
testcase_29 AC 188 ms
40,240 KB
testcase_30 AC 1,028 ms
73,776 KB
testcase_31 AC 216 ms
40,104 KB
testcase_32 AC 1,704 ms
89,388 KB
testcase_33 AC 32 ms
21,676 KB
testcase_34 AC 35 ms
19,632 KB
testcase_35 AC 45 ms
25,776 KB
testcase_36 AC 562 ms
58,160 KB
testcase_37 AC 542 ms
54,320 KB
testcase_38 AC 481 ms
54,444 KB
testcase_39 AC 611 ms
65,836 KB
testcase_40 AC 377 ms
54,316 KB
testcase_41 AC 406 ms
54,440 KB
testcase_42 AC 448 ms
58,156 KB
testcase_43 AC 492 ms
58,280 KB
testcase_44 AC 533 ms
62,252 KB
testcase_45 AC 577 ms
62,124 KB
testcase_46 AC 1,409 ms
89,388 KB
testcase_47 AC 89 ms
27,820 KB
testcase_48 AC 362 ms
46,384 KB
testcase_49 AC 429 ms
54,444 KB
testcase_50 AC 107 ms
31,792 KB
testcase_51 AC 371 ms
46,764 KB
testcase_52 AC 484 ms
54,444 KB
testcase_53 AC 339 ms
50,348 KB
testcase_54 AC 395 ms
50,348 KB
testcase_55 AC 446 ms
50,348 KB
testcase_56 AC 443 ms
50,480 KB
testcase_57 AC 586 ms
58,288 KB
testcase_58 AC 448 ms
50,476 KB
testcase_59 AC 435 ms
50,348 KB
testcase_60 AC 198 ms
40,112 KB
testcase_61 AC 442 ms
50,220 KB
testcase_62 AC 318 ms
46,380 KB
testcase_63 AC 328 ms
46,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int n,r[40];
bitset<16000001> dp[41];
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>r[i];
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<41;j++){
			if(abs(j-20)>(n-i))continue;
			if(abs(j-20)>i)continue;
			dp[j-1]|=dp[j]>>r[i];
		}
		for(int j=40;j--;){
			if(abs(j-20)>(n-i))continue;
			if(abs(j-20)>i)continue;
			dp[j+1]|=dp[j]<<r[i];
		}
		dp[21][8000000+r[i]]=1;
	}
	int ans=800001;
	for(int i=0;i<16000001;i++)if(dp[20][i])ans=min(ans,abs(i-8000000));
	cout<<ans<<"\n";
}
0