結果

問題 No.921 ずんだアロー
ユーザー 東前頭十一枚目東前頭十一枚目
提出日時 2019-11-08 22:10:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 1,685 ms
コンパイル使用メモリ 167,968 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 03:54:30
合計ジャッジ時間 4,904 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

int main() {
	int n; cin >> n;
	vector<int> a;
	int pre = 0, cnt = 1; cin >> pre;
	for(int i = 0; i < n - 1; ++i) {
		int aa; cin >> aa;
		if(pre != aa) {
			a.push_back(cnt);
			cnt = 1;
			pre = aa;
		} else {
			cnt++;
		}
	}
	a.push_back(cnt);
	for(int i : a) {
		cerr << i << endl;
	}
	int nn = a.size();
	int dp[nn + 1] = {};
	int maxi = 0;
	for(int i = 1; i <= nn; ++i) {
		dp[i] = maxi + a[i - 1];
		dp[i] = max(dp[i], dp[i - 1] + a[i] - 1);
		// cout << dp[i] << endl;
		if(i - 1 >= 0) maxi = max(maxi, dp[i - 1]);
	}
	cout << dp[nn] << '\n';
	return 0;
}
0