結果

問題 No.4 おもりと天秤
ユーザー ei1333333ei1333333
提出日時 2014-10-29 22:21:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 1,189 ms
コンパイル使用メモリ 144,412 KB
実行使用メモリ 4,580 KB
最終ジャッジ日時 2023-08-28 23:09:08
合計ジャッジ時間 2,382 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const int INF = 1 << 30;

int main(){
  int N, W[100];
  bool dp[101][10001] = {};
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> W[i];
  }
  dp[0][0] = true;
  for(int i = 0; i < N; i++){
    for(int j = 10000; j >= 0; j--){
      if(j - W[i] >= 0) dp[i + 1][j - W[i]] |= dp[i][j];
      dp[i + 1][j + W[i]] |= dp[i][j];
    }
  }
  if(dp[N][0]) cout << "possible" << endl;
  else cout << "impossible" << endl;
}
0