結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-27 17:50:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 638 bytes |
| コンパイル時間 | 953 ms |
| コンパイル使用メモリ | 73,848 KB |
| 実行使用メモリ | 817,664 KB |
| 最終ジャッジ日時 | 2024-11-27 11:05:15 |
| 合計ジャッジ時間 | 17,024 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 MLE * 10 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
int N;
vector<pii> dp[101];
string ans = "impossible";
int main(void) {
cin >> N;
dp[0].push_back(pii(0, 0));
for (int n = 1; n <= N; ++n) {
int W; cin >> W;
for (size_t idx = 0U; idx < dp[n - 1].size(); ++idx) {
pii pre = dp[n - 1][idx];
dp[n].push_back(pii(pre.first + W, pre.second));
dp[n].push_back(pii(pre.first, pre.second + W));
}
}
for (size_t idx = 0U; idx < dp[N].size(); ++idx) {
if (dp[N][idx].first == dp[N][idx].second) ans = "possible";
}
cout << ans << endl;
return 0;
}