結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
cormoran
|
| 提出日時 | 2016-11-14 12:35:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 702 bytes |
| コンパイル時間 | 1,580 ms |
| コンパイル使用メモリ | 171,348 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-25 22:16:43 |
| 合計ジャッジ時間 | 2,280 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define all(v) v.begin(),v.end()
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
int main() {
int N; cin >> N;
vector<int> W(N); cin >> W;
int sum = accumulate(all(W), 0);
if(sum % 2 == 0) {
vector<bool> ok(sum / 2 + 1);
ok[0] = true;
rep(i, N) {
rep(j, ok.size()) if(ok[j] and j + W[i] < ok.size()) ok[j + W[i]] = true;
}
if(ok.back()) {
cout << "possible" << endl;
return 0;
}
}
cout << "impossible" << endl;
return 0;
}
cormoran