結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
yukkuriesu
|
| 提出日時 | 2017-12-10 11:44:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 988 bytes |
| コンパイル時間 | 1,532 ms |
| コンパイル使用メモリ | 158,340 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-30 11:15:17 |
| 合計ジャッジ時間 | 2,587 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORS(i,a,b) for(int i=a+1;i<=b;i++)
#define REP(i,N) FOR(i,0,N)
#define REPS(i,N) FORS(i,0,N)
#define debug(x) cout<<#x<<"="<<x<<endl
#define debugarr(arr,N,M){REP(i,N){REP(j,M){if(arr[i][j]==INF)printf(" INF");\
else printf("%d",arr[i][j]);} cout<<endl;}}
#define pb push_back
#define pob pop_back
typedef long long ll;
const int INF=100000000;
//--------------------------------------//
int N;
int W[100];
int a=0;
bool dp[101][5001];
int main(){
cin>>N;
REP(i,N){
cin>>W[i];
a+=W[i];
}
if(a%2==1){
cout<<"impossible"<<endl;
goto end; //人生で一回ぐらいは使ってみたかった。許して。
}
a/=2;
REP(i,N) dp[i][0]=true;
REP(i,N){
REP(j,a){
if(j+1-W[i]>=0) dp[i+1][j+1]=(dp[i][j+1]|dp[i][j+1-W[i]]);
else dp[i+1][j+1]=dp[i][j+1];
}
}
debugarr(dp,N+1,a+1);
if(dp[N][a]) cout<<"possible"<<endl;
else cout<<"impossible"<<endl;
end:
return 0;
}
yukkuriesu