結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-25 05:31:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 661 bytes |
| コンパイル時間 | 1,645 ms |
| コンパイル使用メモリ | 174,616 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-23 19:10:36 |
| 合計ジャッジ時間 | 2,514 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 10 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
int N; cin >> N;
vector<int> W(N);
int s = 0;
rep(i,N){
cin >> W[i];
s += W[i];
}
if(s&1){
cout << "impossible" << endl;
return 0;
}
s /= 2;
vector<vector<bool>> dp(N+1,vector<bool>(10101,false));
dp[0][0] = true;
rep(i,N)for(int j=10101;j>=0;j--){
if(dp[i][j]) dp[i+1][j+W[i]] = true;
}
bool ok = false;
rep(i,N) if(dp[i][s]) ok = true;
cout << (ok?"possible":"impossible") << endl;
}