結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-12-31 00:11:51 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 438 bytes |
コンパイル時間 | 1,696 ms |
コンパイル使用メモリ | 158,036 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-16 04:18:45 |
合計ジャッジ時間 | 2,044 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 20 WA * 3 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N,sum=0; cin>>N; int W[N]; bool dp[100*N+101]={false}; for(int i=0;i<N;i++){ cin>>W[i]; sum+=W[i]; } if(sum%2){ printf("impossible\n"); return 0; } dp[0]=true; for(int i=0;i<N;i++){ for(int j=0;j<100*N+101-W[i];j++){ if(dp[j]==true) dp[j+W[i]] =true; } } if(dp[sum/2]==true) printf("possible\n"); else printf("impossible\n"); return 0; }