結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
mogurocker
|
| 提出日時 | 2017-10-15 01:13:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 584 bytes |
| コンパイル時間 | 1,280 ms |
| コンパイル使用メモリ | 157,924 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 14:55:20 |
| 合計ジャッジ時間 | 2,113 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;
int n;
bool dp[10005];
int main(int argc, char const *argv[]) {
ios_base::sync_with_stdio(false);
cin >> n;
int sum = 0;
dp[0] = true;
FOR(i, n) {
int w;
cin >> w;
FOR(j, 10005) {
if (j+w < 10005) dp[j+w] = dp[j+w] || dp[j];
}
sum += w;
}
cout << (sum & 1 || !dp[sum/2] ? "impossible" : "possible") << endl;
return 0;
}
mogurocker