結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
oba
|
| 提出日時 | 2015-01-07 09:40:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 632 bytes |
| コンパイル時間 | 768 ms |
| コンパイル使用メモリ | 62,740 KB |
| 実行使用メモリ | 13,880 KB |
| 最終ジャッジ日時 | 2024-06-13 02:55:08 |
| 合計ジャッジ時間 | 7,638 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 TLE * 1 -- * 4 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(a, b) for(int a=0; a<(int)b; a++)
using namespace std;
int N;
vector <int> W;
bool roop(int max, int sum, int N, int pos){
if(max < sum) return false;
if(max == sum) return true;
for(int i=pos; i<N; i++){
if(roop(max, sum+W[i], N, i+1)) return true;
}
return false;;
}
int main(){
cin >> N;
W.resize(N);
REP(i,N) cin >> W[i];
int sum = 0;
REP(i, N) sum += W[i];
if(sum%2 == 0){
if(roop(sum/2, 0, N, 0)) cout << "possible" << endl;
else cout << "impossible" << endl;
}else{
cout << "impossible" << endl;
}
return 0;
}
oba