結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-28 14:30:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 943 bytes |
| コンパイル時間 | 526 ms |
| コンパイル使用メモリ | 70,224 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-27 12:59:37 |
| 合計ジャッジ時間 | 1,209 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 7 |
ソースコード
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,a,n) for(int i=a;i<n;i++)
#define REP(i,n) for(int i=0;i<=n;i++)
#define SREP(i,a,n) for(int i=a;i<=n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define scan(x) cin >> x
#define print(x) cout << x << endl
#define fastcin {\
cin.tie(0);\
ios::sync_with_stdio(false);\
}
using namespace std;
typedef long long ll;
/* Coding Space */
int N;
int W[101];
int sum, half;
string ans = "impossible";
bool dp[101][5001];
int main(void) {
fastcin;
scan(N);
SREP(n, 1, N) {
scan(W[n]);
sum += W[n];
}
dp[0][0] = true;
half = sum / 2;
SREP(n, 1, N) RREP(w, half) {
dp[n][w] = dp[n - 1][w];
if (w + W[n] <= half) dp[n][w + W[n]] = dp[n][w];
}
if (dp[N][half]) ans = "possible";
if (sum % 2) ans = "impossible";
print(ans);
return 0;
}