#include #if 1 && defined(LOCAL) #include #else #define debug(...) #define line #endif using namespace std; typedef long long ll; typedef long double ld; #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() templatebool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b>N; vectora(N); for(int i=0;i>a[i]; } int sum=accumulate(all(a),0); //dp[何番目までの品物を選ぶか{選ばない,0,1,2,3,4,5,....}][作れる重さ] vector>dp(N+1,vector(sum+1,false)); dp[0][0] = true; for (int i = 0; i < N; ++i) { for (int j = 0; j <= sum+1; ++j) { dp[i+1][j] = dp[i+1][j]||dp[i][j]; if (j >= a[i]) dp[i+1][j] = dp[i+1][j]||dp[i][j-a[i]]; } } if(sum%2==1){ cout<<"impossible"<