結果

問題 No.2918 Divide Applicants Fairly
ユーザー cled0328cled0328
提出日時 2024-10-07 18:26:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,731 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 2,252 ms
コンパイル使用メモリ 203,216 KB
実行使用メモリ 89,516 KB
最終ジャッジ日時 2024-10-07 21:07:28
合計ジャッジ時間 32,011 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
23,720 KB
testcase_01 AC 56 ms
27,820 KB
testcase_02 AC 43 ms
23,848 KB
testcase_03 AC 1,119 ms
79,016 KB
testcase_04 AC 875 ms
70,956 KB
testcase_05 AC 107 ms
31,912 KB
testcase_06 AC 131 ms
36,012 KB
testcase_07 AC 57 ms
27,820 KB
testcase_08 AC 73 ms
27,816 KB
testcase_09 AC 339 ms
48,300 KB
testcase_10 AC 1,512 ms
87,216 KB
testcase_11 AC 642 ms
62,632 KB
testcase_12 AC 307 ms
48,300 KB
testcase_13 AC 176 ms
40,108 KB
testcase_14 AC 124 ms
36,016 KB
testcase_15 AC 776 ms
68,780 KB
testcase_16 AC 1,716 ms
89,388 KB
testcase_17 AC 315 ms
48,300 KB
testcase_18 AC 679 ms
64,816 KB
testcase_19 AC 49 ms
23,592 KB
testcase_20 AC 616 ms
60,588 KB
testcase_21 AC 301 ms
48,304 KB
testcase_22 AC 59 ms
27,824 KB
testcase_23 AC 333 ms
48,304 KB
testcase_24 AC 1,506 ms
87,216 KB
testcase_25 AC 746 ms
64,680 KB
testcase_26 AC 107 ms
33,964 KB
testcase_27 AC 549 ms
60,584 KB
testcase_28 AC 130 ms
36,008 KB
testcase_29 AC 187 ms
40,104 KB
testcase_30 AC 1,022 ms
74,924 KB
testcase_31 AC 206 ms
42,152 KB
testcase_32 AC 1,731 ms
89,388 KB
testcase_33 AC 17 ms
19,632 KB
testcase_34 AC 23 ms
19,756 KB
testcase_35 AC 29 ms
25,768 KB
testcase_36 AC 573 ms
60,588 KB
testcase_37 AC 520 ms
56,496 KB
testcase_38 AC 472 ms
56,360 KB
testcase_39 AC 592 ms
68,780 KB
testcase_40 AC 354 ms
56,492 KB
testcase_41 AC 391 ms
56,496 KB
testcase_42 AC 431 ms
60,588 KB
testcase_43 AC 463 ms
60,588 KB
testcase_44 AC 504 ms
62,640 KB
testcase_45 AC 549 ms
64,688 KB
testcase_46 AC 1,391 ms
89,516 KB
testcase_47 AC 71 ms
29,868 KB
testcase_48 AC 337 ms
48,296 KB
testcase_49 AC 404 ms
56,488 KB
testcase_50 AC 90 ms
33,960 KB
testcase_51 AC 341 ms
48,176 KB
testcase_52 AC 463 ms
56,496 KB
testcase_53 AC 306 ms
52,396 KB
testcase_54 AC 363 ms
52,400 KB
testcase_55 AC 421 ms
52,396 KB
testcase_56 AC 411 ms
52,396 KB
testcase_57 AC 550 ms
60,588 KB
testcase_58 AC 431 ms
52,392 KB
testcase_59 AC 417 ms
52,396 KB
testcase_60 AC 176 ms
40,108 KB
testcase_61 AC 413 ms
52,400 KB
testcase_62 AC 300 ms
48,300 KB
testcase_63 AC 302 ms
48,300 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=7200000;i<8800001;i++)if(dp[20][i])ans=min(ans,abs(i-8000000));
	cout<<ans<<"\n";
}
0