結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
shimashima_k
|
| 提出日時 | 2015-04-28 16:14:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 695 bytes |
| コンパイル時間 | 1,350 ms |
| コンパイル使用メモリ | 159,964 KB |
| 実行使用メモリ | 8,576 KB |
| 最終ジャッジ日時 | 2024-07-05 05:02:04 |
| 合計ジャッジ時間 | 7,897 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 1 TLE * 1 -- * 4 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
int sum;
int x;
vector<int> w;
int solve(int n, int total) {
if (total==sum) return 1;
else if (n > x+2) return 0;
else if (total > sum) return 0;
else if (solve(n+1, total + w[n])==1) return 1;
else if (solve(n+1, total) == 1) return 1;
else return 0;
}
int main() {
sum = 0;
cin>>x;
for(int i=0; i<x;i++) {
int a;
cin >> a;
sum += a;
w.push_back(a);
}
if (sum%2==1){
cout<<"impossible"<<endl;
return 0;
}
sum /= 2;
if (solve(0,0) == 1) {
cout<<"possible"<<endl;
} else {
cout<<"impossible"<<endl;
}
return 0;
}
shimashima_k