結果

問題 No.4 おもりと天秤
ユーザー ssssskkkkkssssskkkkk
提出日時 2017-11-28 14:23:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 884 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 69,456 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 14:50:07
合計ジャッジ時間 1,152 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdlib.h>
#include <iostream>
#include <vector>
#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;
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) SREP(w, 0, 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]) print("possible");
	else print("impossible");
	return 0;
}
0