結果
問題 |
No.921 ずんだアロー
|
ユーザー |
|
提出日時 | 2019-11-08 21:40:05 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 695 bytes |
コンパイル時間 | 798 ms |
コンパイル使用メモリ | 71,424 KB |
実行使用メモリ | 5,720 KB |
最終ジャッジ日時 | 2024-09-15 01:20:58 |
合計ジャッジ時間 | 2,192 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 5 |
ソースコード
#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; }