結果

問題 No.4 おもりと天秤
コンテスト
ユーザー こる
提出日時 2017-01-04 13:08:18
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 600 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 453 ms
コンパイル使用メモリ 79,212 KB
実行使用メモリ 9,728 KB
最終ジャッジ日時 2026-05-26 14:49:03
合計ジャッジ時間 7,328 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<sstream>
using namespace std;

void dfs(int index, int right, int left, int n, vector<int> w){
	if (index == n){
		if (right == left){
			cout << "possible" << endl;
			exit(0);
		}return;
	}

	dfs(index + 1, right + w[index], left, n, w);
	dfs(index + 1, right, left + w[index], n, w);

	return;
}

int main(){
	int n;
	cin >> n;
	vector<int> w;
	int temp;
	for (int i = 0; i < n; i++){
		cin >> temp;
		w.push_back(temp);
	}
	dfs(1, w[0], 0, n, w);
	dfs(1, 0, w[0], n, w);
	cout << "impossible" << endl;
	return 0;
}

0