結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
syaro
|
| 提出日時 | 2017-10-16 22:15:35 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,316 bytes |
| コンパイル時間 | 1,727 ms |
| コンパイル使用メモリ | 167,520 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-17 21:23:02 |
| 合計ジャッジ時間 | 1,949 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n) - 1, 0, i)
#define upto(f, t, i) for(int i##_to_ = (t), i = (f); i <= i##_to_; i++)
#define uptil(f, t, i) for(int i##_to_ = (t), i = (f); i < i##_to_; i++)
#define downto(f, t, i) for(int i##_to_ = (t), i = (f); i >= i##_to_; i--)
#define downtil(f, t, i) for(int i##_to_ = (t), i = (f); i > i##_to_; i--)
typedef long double LD;
#define long long long
#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 2
#define _LIBCPP_DEBUG2 2
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '
signed main() { // long: 64bit
if(!debug) {
cin.tie(0);
ios::sync_with_stdio(0);
}
int N; scanf("%d", &N);
vector<int> pyon(10001, false);
pyon[0] = true;
int sum = 0;
times(N, i) {
int W; scanf("%d", &W);
sum += W;
upto(0, 10000, i) {
for(int j : {i + W, i - W}) {
if(0 <= j && j <= 10000) {
pyon[j] = pyon[j] || pyon[i];
}
}
}
}
cout << (sum % 2 == 0 && pyon[sum / 2] ? "possible" : "impossible") ln;
return 0;
}
syaro