結果

問題 No.1438 Broken Drawers
ユーザー jutama
提出日時 2021-04-17 12:08:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 1,153 bytes
コンパイル時間 4,890 ms
コンパイル使用メモリ 178,380 KB
最終ジャッジ日時 2025-01-20 21:08:17
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
#include <bitset>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using namespace atcoder;

//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//

void input() {
    
    
}


void solve() {
    
    int N; cin >> N;
    vector<pair<int, int>> A(N);
    vector<int> B(N, 1);
    for(int i = 0; i < N; i++) {
        int a; cin >> a;
        A[i] = {a, i};
    }
    sort(A.begin(), A.end());
    
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(B[A[i].second]) {
            ans++;
            if(A[i].second > 0) B[A[i].second - 1] = 0;
        }
    }
    cout << ans << endl;
    
    
}

//* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ *//

int main() {
    
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
    std::cin.tie(0);
    ios::sync_with_stdio(false);
    
    input();
    solve();
    
    return 0;
}
0