結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-10 06:34:47 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 721 bytes |
| 記録 | |
| コンパイル時間 | 378 ms |
| コンパイル使用メモリ | 78,212 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2026-03-13 02:30:52 |
| 合計ジャッジ時間 | 1,034 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <iostream>
#include <vector>
#include <array>
using namespace std;
#define REP(i,first,last) for (int i=first;i<last;i++)
#define FOR(it,con) for (auto it=con.begin();it!=con.end();it++)
int N;
int half;
vector<int> w_list;
bool dp[10001] = {false};
int main(){
cin >> N;
dp[0] = true;
int val;
int total = 0;
REP(i,0,N){
cin >> val;
w_list.push_back(val);
total += val;
}
if (total & 1) {
cout<<"impossible"<<endl;
} else {
half = total >> 1;
for (auto w: w_list) {
for (int i=10000;i>=0;i--) {
if (dp[i] == true) dp[i + w] = true;
}
}
if (dp[half]) {
cout<<"possible"<<endl;
} else {
cout<<"impossible"<<endl;
}
}
}