結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
小指が強い人
|
| 提出日時 | 2016-01-04 09:42:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 607 bytes |
| コンパイル時間 | 501 ms |
| コンパイル使用メモリ | 59,608 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-19 11:09:03 |
| 合計ジャッジ時間 | 2,581 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 RE * 9 |
ソースコード
#include <iostream>
#include <vector>
using namespace std;
int n;
vector<int> w;
bool memo[100][10005] = {0};
bool solve(int i, int wi, int wj)
{
if(memo[i][wi])
return false;
memo[i][wi] = true;
if(i >= n)
return wi == wj;
if(solve(i + 1, wi + w[i], wj))
return true;
if(solve(i + 1, wi, wj + w[i]))
return true;
return false;
}
int main(void)
{
cin >> n;
w.resize(n);
for(int i = 0; i < n; i++)
cin >> w[i];
if(solve(0, 0, 0))
cout << "possible" << endl;
else
cout << "impossible" << endl;
return 0;
}
小指が強い人