結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 08:36:15 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 516 bytes |
| コンパイル時間 | 2,323 ms |
| コンパイル使用メモリ | 194,488 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-04-19 08:36:19 |
| 合計ジャッジ時間 | 3,342 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 WA * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int n; cin >> n;
vector<int> w(n);
int sum=0;
for(int i=0; n>i; ++i){
cin >> w[i]; sum+=w[i];
}
bool dp[sum+1][n+1];
for(int i=0; sum>=i; ++i) for(int j=0; n>=j; ++j) dp[i][j] = false;
dp[0][0]=true;
for(int i=1; n>=i; ++i){
for(int j=1; sum>=j; ++j){
dp[i][j] = dp[i-1][j-w[i-1]];
}
}
if(sum%2 == 0){
if(dp[sum/2][n]){
cout << "possible" << endl;
return 0;
}
}
cout << "impossible" << endl;
}