結果

問題 No.4 おもりと天秤
ユーザー aikiaiki
提出日時 2018-11-26 21:29:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,739 bytes
コンパイル時間 1,476 ms
コンパイル使用メモリ 164,380 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-02 00:35:50
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;


#define SZ(x) ((int)(x).size())
#define BIT(n) (1ll<<(n))
#define SORT(c) sort((c).begin(),(c).end())
#define RALL(a) (a).rbegin(), (a).rend()
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define CLR(a) memset((a), 0 ,sizeof(a))
#define retrun return
//#define INF 1000000010ll
#define MOD 1000000007ll
#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define RREP(i,n)  
#define rep(i,n) for(int i=n-1;i>=0;--i)
#define COUT(str) cout << str << endl


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

//------------------------------------------------------------------------------------------------------

int n, w[110];
const int INF = 1 << 29;
int dp[110][3];
bool flag = false;
//------------------------------------------------------------------------------------------------------

int main() {
	cin >> n;

	REP(i, 0, n) cin >> w[i];

	REP(i, 1, n)REP(j, 0, 2) dp[i][j] = -INF;

	REP(i, 0, n)REP(j,0,2) {
		dp[i + 1][0] = max(dp[i][0], dp[i][1] + w[i]);
		dp[i + 1][1] = max(dp[i][0] + w[i], dp[i][1]);

		if (dp[i + 1][0] == n / 2) flag = true;
		if (dp[i + 1][1] == n / 2) flag = true;
	}

	if (flag) COUT("possible");

	else COUT("impossible");
	


	return 0;
}
0