結果

問題 No.1438 Broken Drawers
ユーザー noritake
提出日時 2021-03-30 09:47:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,727 bytes
コンパイル時間 1,990 ms
コンパイル使用メモリ 194,724 KB
最終ジャッジ日時 2025-01-20 00:51:22
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
// #include <atcoder/all> // NOTE: AtCoderライブラリ
using namespace std;
// using namespace atcoder; // NOTE: AtCoderライブラリ
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl;
#define dbg3(x, y, z) cerr << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;
#define nl() cout << "========================================" << endl;
#define yn { puts("Yes"); } else{ puts("No"); } // 使い方: if (条件) yn; 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<pair<int, int>> vpii;
typedef vector<pair<long long, long long>> vpll;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int main() {
    int N; cin >> N;
    vi A(N); rep(i, N) cin >> A[i];

    int res = 0;
    int cnt = 0;
    rep(i, N - 1) {
        if (A[i] > A[i + 1]) {
            if (cnt == 0) cnt += 2;
            else cnt++;
        } else {
            res += cnt / 2;
            cnt = 0;
        }
    }
    res += cnt / 2;

    cout << (N - res) << endl;
}
0