結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  mmn15277198 | 
| 提出日時 | 2021-01-29 12:21:33 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 645 bytes | 
| コンパイル時間 | 1,597 ms | 
| コンパイル使用メモリ | 168,332 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-06-27 00:07:43 | 
| 合計ジャッジ時間 | 2,369 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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(sum + 110 , 0);
	dp[0] = 1;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < dp.size(); j++){
			if(dp[j] == 1 && j + a[i] < dp.size())dp[j + a[i]] = 1;
			if(dp[sum / 2] == 1){
				cout << "possible" << endl;
				exit(0);
			}
		}
	}
	cout << "impossible" << endl;
	return 0;
}
            
            
            
        