結果

問題 No.1438 Broken Drawers
ユーザー rogi52
提出日時 2022-10-08 15:11:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 544 bytes
コンパイル時間 2,105 ms
コンパイル使用メモリ 202,656 KB
最終ジャッジ日時 2025-02-08 00:27:04
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    vector<pair<int,int>> V(N);
    rep(i,N) V[i] = {A[i], i};

    sort(V.begin(), V.end());
    vector<int> st(N + 1, 0);
    int ans = 0;
    rep(i,N) {
        auto [a, b] = V[i];
        if(st[b + 1] == 0) {
            st[b] = 1;
            ans++;
        }
    }
    cout << ans << endl;
}
0