結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2015-05-27 20:40:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,226 bytes |
コンパイル時間 | 637 ms |
コンパイル使用メモリ | 87,352 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-06 11:04:40 |
合計ジャッジ時間 | 1,537 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 13 WA * 10 |
ソースコード
#include <iostream> #include <iomanip> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <list> #include <string> #define _USE_MATH_DEFINES #include <math.h> #include <stdio.h> #include <stdlib.h> #include <bitset> #define REP(i,n) for(int (i)=0;(i)<(n);(i)++) #define RREP(i,n) for(int (i)=(n)-1;(i)>=0;(i)--) #define debug(x) cout<<x<<endl using namespace std; typedef pair<int,int> P; typedef priority_queue<int> maxpq; typedef priority_queue<int,vector<int>,greater<int> > minpq; typedef priority_queue<P> p_maxpq; typedef priority_queue<P,vector<P>,greater<P> > p_minpq; typedef vector<int> veci; typedef vector<P> vecp; typedef vector<string> vecs; typedef long long int LL; #define INF 2000000000 struct edge{int to,cost;}; int main(void) { int N;cin>>N; int W[100]; REP(i,N) cin >> W[i]; sort(W,W+N); int weight = 0; REP(i,N) weight += W[i]; if(weight%2==1) { cout <<"impossible"<<endl; return 0; } bool dp[100][10000] = {0}; dp[0][W[0]] = true; REP(i,N-1) { dp[i][0] = true; for(int j = 0;j <= weight/2;j++) { if(dp[i][j-W[i+1]]) dp[i+1][j] = true; } } if(dp[N-1][weight/2]) cout <<"possible"<<endl; else cout<<"impossible"<<endl; return 0; }