結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  mmn15277198 | 
| 提出日時 | 2021-01-29 12:03:36 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 603 bytes | 
| コンパイル時間 | 1,507 ms | 
| コンパイル使用メモリ | 169,364 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-26 23:56:43 | 
| 合計ジャッジ時間 | 2,394 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 20 WA * 3 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ld pi = 3.14159265358979;
const int mod = 1000000007;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	int sum = 0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	
	if(sum % 2 == 1){
		cout << "impossible" << endl;
		exit(0);
	}
	vector<int> dp(30000 , 0);
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 20000; j++){
			if(dp[j] == 1)dp[j + a[i]] = 1;
		}
	}
	if(dp[sum / 2] == 1){
		cout << "possible" << endl;
	}else{
		cout << "impossible" << endl;
	}
	return 0;
}
            
            
            
        