結果

問題 No.921 ずんだアロー
ユーザー okok
提出日時 2019-11-08 21:35:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,299 bytes
コンパイル時間 840 ms
コンパイル使用メモリ 89,932 KB
実行使用メモリ 9,432 KB
最終ジャッジ日時 2023-10-13 03:36:14
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,352 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 2 ms
4,348 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 27 ms
8,876 KB
testcase_11 AC 29 ms
9,432 KB
testcase_12 AC 7 ms
4,572 KB
testcase_13 AC 22 ms
8,312 KB
testcase_14 AC 25 ms
8,524 KB
testcase_15 AC 14 ms
6,088 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 25 ms
8,880 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 30 ms
9,276 KB
testcase_24 AC 12 ms
4,568 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 = 110000;
	int N;
	int a = 0, b = 0;
	vector<int> A, used;
	vector<pair<int,int>> B;
	static int dp[3][MAX] = {};
	priority_queue<pair<int,int>> Q;
	
	cin>>N;
	
	A.resize(N);
	used.resize(N+2);
	
	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]});
	}
	
	// for(int i = 0; i < B.size(); i++){ //cout<<i<<endl;
		// if(i%2) a += B[i].first;
		// else b += B[i].first;
	// }
	
	for(int i = 0; i < B.size(); i++){
		// for(int ){
		// }
		
		Q.push(make_pair(B[i].first,i+1));
	}
	
	
	while(!Q.empty()){
		pair<int,int> P = Q.top(); Q.pop();
		int con = P.second;
		
		if(used[con]) continue;
		
		used[con+1] = true;
		used[con] = true;
		used[con-1] = true;
		
		a += P.first;
	}
	
	cout<<max(a,b)<<endl;
	
	
	return 0;
}
0