結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-11 19:34:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 733 bytes |
| コンパイル時間 | 540 ms |
| コンパイル使用メモリ | 63,384 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 10:05:09 |
| 合計ジャッジ時間 | 1,291 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <iostream>
#include <vector>
#include <array>
#include <string>
using namespace std;
const int MAX_N = 100;
int N;
vector<int> w_list;
int total = 0;
vector<bool> result(MAX_N * 100 + 1, false);
#define REP(i,first,last) for (int i=first;i<last;i++)
void solve(){
result[0] = true;
for (auto w: w_list) {
for(int i=10000-w;i>=0;i--) {
if (result[i]) {
result[i+w] = true;
}
}
}
}
int main(){
cin >> N;
REP(i,0,N) {
int val;
cin>>val;
w_list.push_back(val);
total += val;
}
if (total & 1) {
cout<<"impossible"<<endl;
} else {
solve();
if (result[total>>1]) {
cout<<"possible"<<endl;
} else {
cout<<"impossible"<<endl;
}
}
}