結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2018-02-10 23:27:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 638 bytes |
コンパイル時間 | 625 ms |
コンパイル使用メモリ | 68,480 KB |
実行使用メモリ | 8,448 KB |
最終ジャッジ日時 | 2024-11-06 16:18:41 |
合計ジャッジ時間 | 7,240 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 TLE * 1 -- * 17 |
ソースコード
#include<iostream> #include<map> using namespace std; int N,SUM=0; int max(int a,int b){ if(a>b) return a; else return b; } int search(int n,int s,int *w){ if(n!=N-1) return max(search(n+1,s,w),search(n+1,s+w[n],w)); else if(s==SUM/2) return 1; else return 0; } int main(){ int i; cin>>N; int w[N]; for(i=0;i<N;i++){ cin>>w[i]; SUM+=w[i]; } if(SUM%2==1) cout<<"impossible"<<endl; else if(max(search(0,0,&w[0]),search(0,w[0],&w[0]))==1) cout<<"possible"<<endl; else cout<<"impossible"<<endl; return 0; }