結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
Microbe
|
| 提出日時 | 2017-08-03 18:59:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 951 bytes |
| コンパイル時間 | 1,551 ms |
| コンパイル使用メモリ | 166,848 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 20:30:58 |
| 合計ジャッジ時間 | 2,317 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 2 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
bool dp[101][10001];
int main() {
int N, W[100];
int sum = 0;
scanf("%d", &N);
memset(dp, false, sizeof(dp));
rep(i, N) {
scanf("%d", &W[i]);
sum += W[i];
}
dp[0][0] = true;
rep(i, N) {
rep(j, 10001) {
if (dp[i][j]) {
dp[i + 1][j + W[i]] = true;
dp[i + 1][j] = true;
}
}
}
(dp[N][sum / 2]) ? printf("possible\n") : printf("impossible\n");
return 0;
}
Microbe