結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-09-07 16:19:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 822 bytes |
| コンパイル時間 | 462 ms |
| コンパイル使用メモリ | 55,736 KB |
| 実行使用メモリ | 10,016 KB |
| 最終ジャッジ日時 | 2024-11-15 21:05:08 |
| 合計ジャッジ時間 | 13,289 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 TLE * 2 |
ソースコード
#include <iostream>
int sum=0;
bool run(int*mess_list,int mess,int length){
for(int i=0;i< length;i++){
if(mess+mess_list[i]<sum){
int*copy=new int[length-1];
for(int j=0;j<length;j++){
if(i>j){
copy[j]=mess_list[j];
}else if(i<j){
copy[j-1]=mess_list[j];
}
}
bool result=run(copy,mess+mess_list[i],length-1);
delete[] copy;
if(result==true){
return true;
}
}
if(mess+mess_list[i]==sum){
return true;
}
}
return false;
}
int main(){
int n;
std::cin>>n;
int*mess_list=new int[n];
for(int i=0;i<n;i++){
std::cin>>mess_list[i];
}
for(int i=0;i<n;i++){
sum+=mess_list[i];
}
if(sum%2==1){
std::cout<<"impossible"<<std::endl;
return 0;
}
sum/=2;
std::cout<<(run(mess_list,0,n)?"possible":"impossible")<<std::endl;
delete[] mess_list;
return 0;
}