結果
| 問題 | No.921 ずんだアロー |
| コンテスト | |
| ユーザー |
amaridekinai
|
| 提出日時 | 2019-11-10 19:53:19 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,095 bytes |
| 記録 | |
| コンパイル時間 | 1,648 ms |
| コンパイル使用メモリ | 170,544 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 05:04:16 |
| 合計ジャッジ時間 | 2,914 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 5 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int N; cin >> N;
vector<int> A(N);
for(int i = 0; i < N; i++){ cin >> A[i];}
int head = 0; int tail = 0;
int ans = 0;
vector<bool> flag(N,false);
while( head < N && tail < N){
while( A[head] == A[tail]){ tail++;}
if( tail-head >= 2){
for(int i = head; i < tail; i++){ flag[i] = true;}
}
head = tail;
}
head = 0; tail = 0;
int cnt = 0;
while( head < N && tail < N){
if( flag[head]){
while( flag[tail] && tail < N) { tail++;}
cnt += tail-head;
head = tail;
}
else{
while( !flag[tail] && tail < N){ tail++;}
if( (tail-head)%2){
if( head == 0 && tail == N){ cnt += (tail-head+1)/2;}
else{cnt += (tail-head-1)/2;}
}
else{
if( head == 0 || tail == N){
cnt += (tail-head)/2;}
else{
cnt += (tail-head-2)/2;}
}
head = tail;
}
}
cout << cnt << endl; return 0;
}
amaridekinai