結果
問題 |
No.921 ずんだアロー
|
ユーザー |
![]() |
提出日時 | 2019-11-08 22:21:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 1,625 ms |
コンパイル使用メモリ | 172,116 KB |
実行使用メモリ | 5,796 KB |
最終ジャッジ日時 | 2024-09-15 01:36:23 |
合計ジャッジ時間 | 2,707 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 WA * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; using lint = long long; template<class T = int> using V = vector<T>; template<class T = int> using VV = V< V<T> >; template<class Itr> auto rle(Itr first, Itr last) { V< pair<decltype(*first), int> > res; for (; first != last; ++first) { if (res.empty() or res.back().first != *first) { res.emplace_back(*first, 1); } else { ++res.back().second; } } return res; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; V<> a(n); for (auto&& e : a) cin >> e; V<> dp(2); for (const auto& e : rle(begin(a), end(a))) { V<> ndp(2); ndp[0] = max(dp[0], dp[1]); ndp[1] = dp[0] + e.second; swap(dp, ndp); } cout << max(dp[0], dp[1]) << '\n'; }