結果

問題 No.921 ずんだアロー
ユーザー nanophoto12nanophoto12
提出日時 2020-01-05 00:59:30
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 926 bytes
コンパイル時間 1,970 ms
コンパイル使用メモリ 203,960 KB
実行使用メモリ 9,604 KB
最終ジャッジ日時 2023-08-14 20:56:54
合計ジャッジ時間 3,522 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 33 ms
8,548 KB
testcase_11 AC 36 ms
9,012 KB
testcase_12 AC 9 ms
4,384 KB
testcase_13 AC 25 ms
7,228 KB
testcase_14 AC 29 ms
8,144 KB
testcase_15 AC 18 ms
5,908 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 30 ms
8,016 KB
testcase_18 AC 37 ms
9,340 KB
testcase_19 AC 36 ms
9,388 KB
testcase_20 AC 37 ms
9,280 KB
testcase_21 AC 36 ms
9,604 KB
testcase_22 AC 37 ms
9,288 KB
testcase_23 AC 36 ms
9,452 KB
testcase_24 AC 36 ms
9,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:1:9: 警告: #pragma once がメインファイルにあります
    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