結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-07-20 19:29:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 848 bytes |
コンパイル時間 | 1,426 ms |
コンパイル使用メモリ | 157,680 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-15 17:55:49 |
合計ジャッジ時間 | 2,969 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 WA * 3 RE * 5 |
ソースコード
// g++ -std=c++11 temp.cpp #include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define REP(i,n) FOR(i,0,n) #define EACH(itr,v) for(auto itr:v) #define pb(s) push_back(s) #define mp(a,b) make_pair(a,b) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<P, int> PPI; #define INF INT_MAX/3 #define MAX_N 1000 int n; int w[100]; int sum = 0; bool dp[11111]; int main(){ cin>>n; REP(i,n){ cin>>w[i]; sum += w[i]; } if(sum%2==1){ cout<<"impossible"<<endl; return 0; } sum/=2; REP(i,11111) dp[i] = false; dp[0] = true; REP(i,n){ REP(j,11111){ if(dp[j]) dp[j+w[i]] = true; } } if(dp[sum]) cout<<"possible"<<endl; else cout<<"impossible"<<endl; return 0; }