結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
Kutimoti_T
|
| 提出日時 | 2017-12-17 16:02:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 863 bytes |
| コンパイル時間 | 601 ms |
| コンパイル使用メモリ | 72,824 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-15 22:26:38 |
| 合計ジャッジ時間 | 2,753 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 14 RE * 9 |
ソースコード
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define FOR(i,s,e) for(int i = (s);i <= (e);i++)
vector<vector<bool>> dp(100,vector<bool>(5050,false));
int W[101];
int N;
int total = 0;
int main()
{
cin >> N;
FOR(i,0,N - 1)
{
cin >> W[i];
total += W[i];
}
cout << total << endl;
if(total % 2 == 1)
{
cout << "impossible" << endl;
return 0;
}
dp[0][0] = true;
FOR(i,0,N - 1)
{
FOR(j,0,5049)
{
dp[i + 1][j] = dp[i][j] || dp[i + 1][j];
if(dp[i][j])
{
dp[i + 1][j + W[i]] = true;
}
}
}
if(dp[N][total / 2]) cout << "possible" << endl;
else cout << "impossible" << endl;
return 0;
}
Kutimoti_T