結果

問題 No.4 おもりと天秤
ユーザー Asdf_QwertyZAsdf_QwertyZ
提出日時 2018-06-05 23:11:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 500 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 31,852 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-12 22:36:38
合計ジャッジ時間 1,480 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int MAX_N = 100;

int N;
int W[MAX_N], S;
bool dp[101];

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", W+i ), S += W[i];

  if( S % 2 == 1 )
  {
    puts("impossible");

    return 0;
  }

  dp[0] = true;
  rep( i, N ) rep( j, 101 ) if( j-W[i] >= 0 )
    dp[j] |= dp[j-W[i]];

  puts( dp[S/2] ? "possible" : "impossible" );
  
  return 0;
}
0