結果

問題 No.921 ずんだアロー
ユーザー nanophoto12nanophoto12
提出日時 2020-01-05 00:59:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 2,511 ms
コンパイル使用メモリ 204,416 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2024-05-02 09:03:57
合計ジャッジ時間 3,759 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 35 ms
8,832 KB
testcase_11 AC 38 ms
9,344 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 28 ms
7,552 KB
testcase_14 AC 32 ms
8,192 KB
testcase_15 AC 20 ms
6,144 KB
testcase_16 AC 4 ms
5,376 KB
testcase_17 AC 32 ms
8,320 KB
testcase_18 AC 39 ms
9,472 KB
testcase_19 AC 38 ms
9,472 KB
testcase_20 AC 39 ms
9,472 KB
testcase_21 AC 42 ms
9,472 KB
testcase_22 AC 39 ms
9,472 KB
testcase_23 AC 38 ms
9,472 KB
testcase_24 AC 39 ms
9,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~

ソースコード

diff #

#pragma once

#include <bits/stdc++.h>

//https://atcoder.jp/contests/abc140/tasks/abc140_e
//n x n では間に合わない
//各要素が2番目に大きくなる組み合わせを調べて数え上げていく

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(int a = 0;a < n;a++)
#define repi(a,b,n) for(int a = b;a < n;a++)

const ull mod = 1e9+7;

int main(void)
{
	ll n;
	cin >> n;
	vector<ll> vs(n+1, 1e7);
	rep(i, n) cin >> vs[i+1];

	vector<vector<ll>> dp(n + 1, vector<ll>(2,0));
	dp[0][0] = 0;
	dp[0][1] = 0;
	rep(i, n) {
		dp[i + 1][0] = max(dp[i][0], dp[i][1]);
		dp[i + 1][1] = dp[i][0] + 1;
		if (vs[i + 1] == vs[i]) 
		{
			dp[i + 1][1] = max(dp[i+1][1], dp[i][1] + 1);
		}
	}
	cout << max(dp[n][0], dp[n][1]) << endl;
	return 0;
}
0