結果

問題 No.921 ずんだアロー
ユーザー RTnFRTnF
提出日時 2019-11-08 23:39:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 1,936 bytes
コンパイル時間 1,956 ms
コンパイル使用メモリ 201,548 KB
実行使用メモリ 4,688 KB
最終ジャッジ日時 2023-10-13 05:26:13
合計ジャッジ時間 3,270 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 11 ms
4,532 KB
testcase_11 AC 11 ms
4,684 KB
testcase_12 AC 4 ms
4,352 KB
testcase_13 AC 9 ms
4,348 KB
testcase_14 AC 10 ms
4,352 KB
testcase_15 AC 6 ms
4,352 KB
testcase_16 AC 3 ms
4,356 KB
testcase_17 AC 10 ms
4,400 KB
testcase_18 AC 12 ms
4,508 KB
testcase_19 AC 12 ms
4,680 KB
testcase_20 AC 12 ms
4,504 KB
testcase_21 AC 12 ms
4,676 KB
testcase_22 AC 12 ms
4,648 KB
testcase_23 AC 12 ms
4,688 KB
testcase_24 AC 12 ms
4,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

const int MAX = 100010;
int dp[MAX][2];

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n);
    rep(i, n){
        cin >> a[i];
    }
    dp[0][0] = 1;
    dp[0][1] = 0;
    repr(i, 1, n){
        if(a[i] == a[i-1]){
            dp[i][0] = max(dp[i-1][0], dp[i-1][1]) + 1;
            dp[i][1] = max(dp[i-1][0], dp[i-1][1]);
        }else{
            dp[i][0] = dp[i-1][1] + 1;
            dp[i][1] = max(dp[i-1][0], dp[i-1][1]);
        }
    }
    cout << max(dp[n-1][0], dp[n-1][1]) << endl;
    return 0;
}
0