結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-04-03 20:34:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 891 bytes |
| コンパイル時間 | 3,786 ms |
| コンパイル使用メモリ | 173,228 KB |
| 最終ジャッジ日時 | 2025-01-28 14:47:31 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 WA * 8 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)
int main(){
int n;
cin >> n;
vector<vector<bool>> dp(n+1,vector<bool> (2000));
int sum = 0;
vector<int> a(n);
rep(i,n){
cin >> a[i];
sum += a[i];
}
dp[0][0] = true;
for (int i = 0; i < n;i++){
for (int j = 0; j <= 1000;j++){
if (dp[i][j]){
dp[i+1][j] = true;
dp[i+1][j+a[i]] = true;
}
}
}
bool yes = false;
for (int w = 0; w <= 1000;w++){
if (dp[n][w] && w*2 == sum){
yes = true;
break;
}
}
if (yes) cout << "possible" << endl;
else cout << "impossible" << endl;
return 0;
}