結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
dgd1724
|
| 提出日時 | 2016-11-27 20:11:48 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,010 bytes |
| コンパイル時間 | 1,357 ms |
| コンパイル使用メモリ | 161,060 KB |
| 実行使用メモリ | 10,020 KB |
| 最終ジャッジ日時 | 2024-11-27 12:18:09 |
| 合計ジャッジ時間 | 8,309 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 9 RE * 13 TLE * 1 |
ソースコード
#include <bits/stdc++.h>
//const static double de_PI = 3.14159265358979323846;
//const static double de_EPS = 0.000001;
//const static int de_MOD = 1000000007;
//const static int de_MAX = 999999999;
//const static int de_MIN = -999999999;
inline void Calc(const int &sum, const int &count, const int &idx, const std::vector<int> &W, const int &target) {
if (sum == target) {
std::cout << "possible" << std::endl;
exit(1);
}
if (count <= 0) { return; }
if (idx >= static_cast<int>(W.size())) { return; }
Calc(sum + W[idx], count - 1, idx + 1, W, target);
Calc(sum, count, idx + 1, W, target);
}
int main(void) {
//std::ifstream inf("123.txt"); std::cin.rdbuf(inf.rdbuf());
int N = 0;
std::cin >> N;
std::vector<int> W(N);
for (int i = 0; i < N; i++) { std::cin >> W[i]; }
int total = std::accumulate(W.begin(), W.end(), 0);
if (total % 2 != 0) {
std::cout << "impossible" << std::endl;
return 0;
}
Calc(0, N / 2, 0, W, total / 2);
std::cout << "impossible" << std::endl;
}
dgd1724