結果

問題 No.4 おもりと天秤
ユーザー DAyamaCTFDAyamaCTF
提出日時 2016-07-20 19:29:11
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 848 bytes
コンパイル時間 1,083 ms
コンパイル使用メモリ 159,552 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 17:22:27
合計ジャッジ時間 2,444 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// g++ -std=c++11 temp.cpp
#include <bits/stdc++.h>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3

#define MAX_N 1000

int n;
int w[100];
int sum = 0;
bool dp[11111];

int main(){
	cin>>n;
	REP(i,n){
		cin>>w[i];
		sum += w[i];
	}
	if(sum%2==1){
		cout<<"impossible"<<endl;
		return 0;
	}
	sum/=2;
	REP(i,11111) dp[i] = false;
	dp[0] = true;
	REP(i,n){
		REP(j,11111){
			if(dp[j]) dp[j+w[i]] = true;
		}
	}
	if(dp[sum]) cout<<"possible"<<endl;
	else cout<<"impossible"<<endl;

	return 0;
}


0