結果

問題 No.284 門松と魔法(2)
ユーザー togari_takamototogari_takamoto
提出日時 2015-10-08 08:26:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 837 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 63,192 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 07:54:54
合計ジャッジ時間 1,900 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 1 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,380 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 28 ms
4,380 KB
testcase_33 AC 26 ms
4,376 KB
testcase_34 AC 29 ms
4,380 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 15 ms
4,376 KB
testcase_38 WA -
testcase_39 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

#define TEN(x) ((ll)1e##x)

enum State{High, Low};

ll calc(const vector<ll> & a ,State s) {
	ll count = 0;
	ll prepre_size = (s==Low) ? 0 : TEN(6)+1;
	ll prev_size = (s==High) ? 0 : TEN(6)+1;
	for (auto& x : a) {
		if (prepre_size == x) {
			count++; continue;
		}

		if (s == High) {
			if (prev_size < x) {
				prepre_size = prev_size;
				s = Low;
			} else {
				count++;
			}
		} else {
			if (prev_size > x) {
				prepre_size = prev_size;
				s = High;
			} else {
				count++;
			}
		}
		prev_size = x;
	}
	return a.size() - count;
}

int main(){
	ll n; cin >> n;
	vector<ll> a(n);
	for (auto& i : a) cin >> i;
	ll result = max(calc(a, Low), calc(a, High));
	if (result < 3) result = 0;
	cout << result << endl;
	return 0;
}
0