結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-01-13 17:50:06 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 547 bytes |
コンパイル時間 | 1,221 ms |
コンパイル使用メモリ | 158,984 KB |
実行使用メモリ | 14,172 KB |
最終ジャッジ日時 | 2024-09-19 18:56:24 |
合計ジャッジ時間 | 8,047 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 6 RE * 2 TLE * 1 -- * 14 |
ソースコード
#include<bits/stdc++.h> using namespace std; int n,w[100]; int memo[100][10001]; bool solve(int i,int wl,int wr){ if(wl==wr && i==n){ return true; } if(i>n){ return false; } if(memo[i][wl]!=-1){ return memo[i][wl]; } if(solve(i+1,wl+w[i],wr)){ return true; } if(solve(i+1,wl,wr+w[i])){ return true; } return false; } int main(){ cin>>n; for(int i=0;i<n;i++) cin>>w[i]; memset(memo,-1,sizeof(memo)); if(solve(0,0,0)==true){ cout<<"possible"<<endl; }else{ cout<<"impossible"<<endl; } }