結果

問題 No.921 ずんだアロー
ユーザー K. YanagisawaK. Yanagisawa
提出日時 2019-11-08 21:40:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 695 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 72,040 KB
実行使用メモリ 5,428 KB
最終ジャッジ日時 2023-10-13 03:41:13
合計ジャッジ時間 2,497 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,356 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 27 ms
5,396 KB
testcase_11 AC 29 ms
5,220 KB
testcase_12 AC 8 ms
4,348 KB
testcase_13 AC 21 ms
4,904 KB
testcase_14 AC 24 ms
4,872 KB
testcase_15 AC 15 ms
4,352 KB
testcase_16 AC 4 ms
4,348 KB
testcase_17 AC 25 ms
4,924 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 30 ms
5,428 KB
testcase_24 AC 28 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

typedef long long int llint;

int main(void){
  llint n;
  std::cin >> n;
  std::vector<llint> A(n);

  llint last = -1;
  llint count = 0;
  std::vector<llint> tunagari;
  for(int i=0; i<n; i++){
    std::cin >> A[i];
    if(i){
      if(last != A[i]){
	tunagari.push_back(count);
	count = 0;
      }
    }
    last = A[i];
    count++;
  }
  if(count) tunagari.push_back(count);
  if(tunagari.size()%2) tunagari.push_back(0);

  std::vector<llint> dp(tunagari.size()+2);
  for(int i=tunagari.size()-1; i>=0; i--){
    llint a = dp[i+2] + tunagari[i];
    llint b = dp[i+1];
    dp[i] = a<b?b:a;
  }
  
  std::cout << dp[0] << std::endl;
  
  return 0;
}
0