結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
hirokazu1020
|
| 提出日時 | 2015-04-21 20:48:12 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 686 bytes |
| コンパイル時間 | 698 ms |
| コンパイル使用メモリ | 81,368 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 09:10:38 |
| 合計ジャッジ時間 | 1,461 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define indexOf(v,x) (find(all(v),x)-v.begin())
int main(){
bool dp[5101]={};
int n,s=0;
cin>>n;
dp[0]=true;
rep(i,n){
int w;
cin>>w;
s+=w;
for(int j=5000;j>=0;j--){
dp[w+j]|=dp[j];
}
}
cout<<(s%2==0&&dp[s/2]?"possible":"impossible")<<endl;
return 0;
}
hirokazu1020