結果

問題 No.4 おもりと天秤
ユーザー ssssskkkkkssssskkkkk
提出日時 2017-11-28 13:55:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 882 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 69,464 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-05 14:49:02
合計ジャッジ時間 1,179 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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;
	dp[0][0] = true;
	scan(N);
	SREP(n, 1, N) {
		scan(W[n]);
		sum += W[n];
	}
	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