結果

問題 No.505 カードの数式2
ユーザー Kmcode1Kmcode1
提出日時 2017-04-21 23:02:48
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 970 bytes
コンパイル時間 1,601 ms
コンパイル使用メモリ 151,428 KB
実行使用メモリ 5,740 KB
最終ジャッジ日時 2023-09-27 12:29:02
合計ジャッジ時間 4,133 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 5 ms
4,436 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 RE -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 RE -
testcase_08 AC 2 ms
4,380 KB
testcase_09 RE -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 RE -
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 RE -
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 RE -
testcase_20 AC 1 ms
4,380 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 7 ms
5,360 KB
testcase_27 AC 6 ms
5,740 KB
testcase_28 AC 5 ms
4,384 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 6 ms
5,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define MAX 16

vector<int> v;

vector<long long int> s[MAX];

int main(){
	int way = 1;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		int a;
		scanf("%d", &a);
		v.push_back(a);
	}
	int bet = n - 1;
	s[0].push_back(v[0]);
	for (int i = 0; i < bet; i++){
		sort(s[i].begin(), s[i].end());
		for (int j = 0; j < s[i].size(); j++){
			if (j>0 && j + 1 < s[i].size()&&s[i][j]!=0&&s[i][j+1]!=0&&s[i][j-1]!=0){
				long long int ty = s[i][j] / abs(s[i][j]);
				long long int ty1 = s[i][j - 1] / abs(s[i][j - 1]);
				long long int ty2 = s[i][j + 1] / abs(s[i][j + 1]);
				if (ty == ty1&&ty == ty2)continue;
			}
			s[i + 1].push_back(s[i][j] * v[i + 1]);
			s[i + 1].push_back(s[i][j] / v[i + 1]);
			s[i + 1].push_back(s[i][j] + v[i + 1]);
			s[i + 1].push_back(s[i][j] - v[i + 1]);
		}
	}
	sort(s[bet].begin(), s[bet].end());
	printf("%lld\n", s[bet].back());
	return 0;
}
0