結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2017-11-27 19:03:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 648 bytes |
コンパイル時間 | 664 ms |
コンパイル使用メモリ | 70,348 KB |
実行使用メモリ | 32,640 KB |
最終ジャッジ日時 | 2024-11-27 11:18:50 |
合計ジャッジ時間 | 61,661 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 TLE * 10 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <numeric> #include <algorithm> using namespace std; typedef pair<int, int> pii; int N; bool dp[10001][10001]; string ans = "impossible"; int main(void) { cin >> N; dp[0][0] = true; const int max = 100 * N; for (int n = 0; n < N; ++n) { int W; cin >> W; for (int l = max; l >= 0; --l) { for (int r = max; r >= 0; --r) { if (max < l + W || max < r + W) continue; if (dp[l][r]) { dp[l][r + W] = dp[l + W][r] = true; dp[l][r] = false; } } } } for (int n = 1; n <= max; ++n) { if (dp[n][n]) ans = "possible"; } cout << ans << endl; return 0; }