結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
MOB_raito
|
| 提出日時 | 2016-01-13 17:52:22 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 583 bytes |
| 記録 | |
| コンパイル時間 | 976 ms |
| コンパイル使用メモリ | 175,888 KB |
| 実行使用メモリ | 7,924 KB |
| 最終ジャッジ日時 | 2026-03-13 01:52:30 |
| 合計ジャッジ時間 | 1,732 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
int n,w[110];
int memo[110][10010];
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 memo[i][wl]=true;
}
if(solve(i+1,wl,wr+w[i])){
return memo[i][wl]=true;
}
return memo[i][wl]=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;
}
}
MOB_raito