結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2017-06-06 23:42:30 |
言語 | C (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 596 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 29,440 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-22 11:53:21 |
合計ジャッジ時間 | 2,293 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 RE * 9 |
ソースコード
#include <stdio.h> int n,w[100],dp[100][10000]; int op(int i,int v){ if(v<0){ return -1; } if(dp[i][v]==0){ if(i==n) dp[i][v]=v?-1:1; else{ if(op(i+1,v)==1) dp[i][v]=1; if(op(i+1,v-2*w[i])==1) dp[i][v]=1; if(dp[i][v]==0) dp[i][v]=-1; } } return dp[i][v]; } int main(void){ scanf("%d",&n); int i,x=0; for(i=0;i<n;i++){ scanf("%d",&w[i]); x+=w[i]; } puts(op(0,x)==1?"possible":"impossible"); }