結果
| 問題 | No.1438 Broken Drawers | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-07-15 11:29:47 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 24 ms / 2,000 ms | 
| コード長 | 814 bytes | 
| コンパイル時間 | 1,955 ms | 
| コンパイル使用メモリ | 193,792 KB | 
| 最終ジャッジ日時 | 2025-01-11 20:59:16 | 
| ジャッジサーバーID (参考情報) | judge5 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 25 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
int main() {
    init();
    
    int n; cin >> n;
    VI a(n); cin >> a;
    int ans = n, cnt = 1;
    FOR(i, 1, n) {
        if (a[i - 1] > a[i])++cnt;
        else {
            ans -= cnt >> 1;
            cnt = 1;
        }
    }
    ans -= cnt >> 1;
    print(ans);
    return 0;
}
            
            
            
        