結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-02-07 00:21:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 668 bytes |
| コンパイル時間 | 689 ms |
| コンパイル使用メモリ | 60,912 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-23 10:30:13 |
| 合計ジャッジ時間 | 1,606 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 WA * 12 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstring>
#include <climits>
#include <cmath>
#define N_MAX 100
using namespace std;
int N, W[N_MAX];
bool cal(int n, int s)
{
if (s == 0)
return true;
if (s < 0 || n >= N)
return false;
s -= W[n];
for (int i = n + 1; i < N; ++i)
if (cal(n + i, s))
return true;
return false;
}
bool cal(int s)
{
if (s & 1)
return false;
s /= 2;
for (int i = 0; i < N; ++i)
if (cal(i, s))
return true;
return false;
}
int main()
{
int sum = 0;
cin >> N;
for (int i = 0; i < N; ++i)
{
cin >> W[i];
sum += W[i];
}
if (cal(sum))
cout << "possible";
else
cout << "impossible";
return 0;
}