結果

問題 No.4 おもりと天秤
ユーザー nxterunxteru
提出日時 2017-06-06 23:59:33
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 376 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 29,924 KB
実行使用メモリ 5,720 KB
最終ジャッジ日時 2023-10-23 18:02:06
合計ジャッジ時間 1,009 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 3 ms
5,720 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 4 ms
5,720 KB
testcase_08 AC 3 ms
5,684 KB
testcase_09 AC 3 ms
5,720 KB
testcase_10 AC 3 ms
5,720 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 3 ms
5,720 KB
testcase_20 AC 3 ms
5,720 KB
testcase_21 AC 3 ms
5,720 KB
testcase_22 AC 3 ms
5,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
int n,w[100],dp[100][10000];

int main(void){
   scanf("%d",&n);
   int i,j,x=0;
   for(i=0;i<n;i++){
       scanf("%d",&w[i]);
       x+=w[i];
   }
   dp[n][0]=1;
   for(i=n-1;i>=0;i--){
       for(j=0;j<10000;j++){
           dp[i][j]=dp[i+1][j]>dp[i+1][j+2*w[i]]?dp[i+1][j]:dp[i+1][j+2*w[i]];
       }
   }
   puts(dp[0][x]?"possible":"impossible");
}  
0