結果
問題 | No.921 ずんだアロー |
ユーザー |
|
提出日時 | 2019-11-08 23:51:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 661 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 35,568 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-15 02:55:42 |
合計ジャッジ時間 | 1,675 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:15:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | int n; scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:16:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | REP(i, n) scanf("%d", &A[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <stdio.h> #include <array> #include <algorithm> #define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i)) #define REP(i, n) FOR(i, 0, n) constexpr int N = 1e5; std::array<int, N> A; std::array<std::array<int, 2>, N> DP; int main(void){ int n; scanf("%d", &n); REP(i, n) scanf("%d", &A[i]); DP[0][0] = 0; DP[0][1] = 1; for(int x = 1; x < n; ++x){ if(A[x-1] == A[x]){ DP[x][0] = DP[x-1][1]; DP[x][1] = DP[x-1][1] + 1; } else{ DP[x][0] = DP[x-1][1]; DP[x][1] = DP[x-1][0] + 1; } } printf("%d\n", std::max(DP[n-1][0], DP[n-1][1])); return 0; }