結果
| 問題 |
No.921 ずんだアロー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-29 13:51:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,141 bytes |
| コンパイル時間 | 1,737 ms |
| コンパイル使用メモリ | 165,164 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-02 13:26:33 |
| 合計ジャッジ時間 | 2,920 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 5 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF = 1e9;
const int MOD = 1000000007;
int main(){
int n;
cin >> n;
vector<int> a(n);
rep(i,n) cin >> a[i];
int ans = 0;
vector<P> k = {P(a[0],0)};
rep(i,n){
if(k.back().first == a[i]){
k.back().second ++;
}else{
k.emplace_back(P(a[i],1));
}
}
bool ok = true;
rep(i,k.size()){
if(k[i].second > 1) ans += k[i].second - 1;
else{
if(ok){
if(0 < i && i < n-1){
if(k[i-1].second > 1 && k[i+1].second > 1){
ans += 2;
ok = false;
}
else{
ans ++;
ok = false;
}
}
else{
ans ++;
ok = false;
}
}else{
ok = true;
}
}
}
cout << ans << endl;
return 0;
}