結果

問題 No.921 ずんだアロー
ユーザー okok
提出日時 2019-11-08 22:11:48
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,060 bytes
コンパイル時間 923 ms
コンパイル使用メモリ 94,156 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2023-10-13 03:54:55
合計ジャッジ時間 2,176 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 14 ms
7,380 KB
testcase_11 AC 15 ms
7,716 KB
testcase_12 AC 5 ms
4,348 KB
testcase_13 AC 12 ms
6,128 KB
testcase_14 AC 12 ms
6,792 KB
testcase_15 AC 8 ms
5,168 KB
testcase_16 AC 2 ms
4,352 KB
testcase_17 AC 13 ms
6,812 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 16 ms
7,684 KB
testcase_24 AC 11 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	const int MAX = 110'000;
	int N;
	int a = 0, b = 0;
	vector<int> A;
	vector<pair<int,int>> B;
	vector<vector<int>> dp;
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i];
		
		if(B.size() == 0) B.push_back({1,A[i]});
		else if(B.back().second == A[i]) B.back().first++;
		else B.push_back({1,A[i]});
	}
	
	dp.resize(2, vector<int>(B.size()+10));
	
	for(int i = 0; i < B.size(); i++){
	
		dp[0][i+1] = max(dp[0][i+1], dp[0][i]);
		dp[0][i+1] = max(dp[0][i+1], dp[1][i]);
		dp[1][i+1] = max(dp[1][i+1], dp[0][i]+B[i].first);
	}
	
	cout<<max(dp[1][B.size()], dp[0][B.size()])<<endl;
	
	
	return 0;
}
0