結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2016-07-20 21:45:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 935 bytes |
コンパイル時間 | 1,337 ms |
コンパイル使用メモリ | 159,868 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-26 09:36:54 |
合計ジャッジ時間 | 2,259 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
// 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[111][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,111)REP(j,11111) dp[i][j] = false; dp[0][0] = true; REP(i,n){ REP(j,11111){ if(dp[i][j]){ dp[i+1][j] = true; dp[i+1][j+w[i]] = true; //dbg(i); dbg(j); } } } if(dp[n][sum]) cout<<"possible"<<endl; else cout<<"impossible"<<endl; return 0; }