結果
問題 |
No.921 ずんだアロー
|
ユーザー |
|
提出日時 | 2019-11-08 21:37:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 649 bytes |
コンパイル時間 | 814 ms |
コンパイル使用メモリ | 71,296 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 01:17:37 |
合計ジャッジ時間 | 2,126 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 5 |
ソースコード
#include <iostream> #include <vector> int main(void){ int n; std::cin >> n; std::vector<int> A(n); int last = -1; int count = 0; std::vector<int> 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<int> dp(tunagari.size()+2); for(int i=tunagari.size()-1; i>=0; i--){ int a = dp[i+2] + tunagari[i]; int b = dp[i+1]; dp[i] = a<b?b:a; } std::cout << dp[0] << std::endl; return 0; }