結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
Dadarithm
|
| 提出日時 | 2015-09-14 23:14:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 623 bytes |
| コンパイル時間 | 552 ms |
| コンパイル使用メモリ | 62,372 KB |
| 実行使用メモリ | 8,576 KB |
| 最終ジャッジ日時 | 2024-07-19 06:31:59 |
| 合計ジャッジ時間 | 6,936 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 TLE * 1 -- * 17 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N; vector<int> arr; bool ans;
bool solve(int n, int left)
{
if (n == arr.size())
return !left;
if (left < 0)
return false;
else
{
if (solve(n + 1, left) || solve(n + 1, left - arr[n]))
return true;
return false;
}
}
int main()
{
ans = false;
cin >> N;
for (int i = 0; i < N; ++i)
{
int j;
cin >> j;
arr.push_back(j);
}
int sum = 0, nsum = 0;
for (int i = 0; i < arr.size(); ++i)
sum += arr[i];
if (!(sum % 2))
ans = solve(0, sum / 2);
cout << (ans ? "possible" : "impossible") << endl;
return 0;
}
Dadarithm