結果

問題 No.4 おもりと天秤
ユーザー cureskolcureskol
提出日時 2020-03-27 08:46:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 421 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 166,880 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 16:11:07
合計ジャッジ時間 2,805 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int dp[100000];
template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n;cin>>n;
  vector<int> w(n);
  for(int i=0;i<n;i++)cin>>w[i];
  int sum=0;
  for(int i=0;i<n;i++)sum+=w[i];
  if(sum&1)fin("impossible");
  dp[0]=1;
  for(int i=0;i<n;i++)for(int j=10000;j>=0;j--)dp[j+w[i]]+=dp[j];
  if(!dp[n/2])cout<<"im";
  cout<<"possible"<<endl;
}
0