結果

問題 No.1438 Broken Drawers
ユーザー se1ka2se1ka2
提出日時 2021-03-26 21:24:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 71,120 KB
実行使用メモリ 6,148 KB
最終ジャッジ日時 2023-08-19 07:00:04
合計ジャッジ時間 3,112 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,076 KB
testcase_01 AC 2 ms
4,880 KB
testcase_02 AC 2 ms
5,128 KB
testcase_03 AC 3 ms
5,044 KB
testcase_04 AC 2 ms
4,896 KB
testcase_05 AC 2 ms
4,988 KB
testcase_06 AC 56 ms
6,148 KB
testcase_07 AC 55 ms
5,860 KB
testcase_08 AC 2 ms
4,872 KB
testcase_09 AC 3 ms
4,916 KB
testcase_10 AC 3 ms
4,880 KB
testcase_11 AC 5 ms
4,964 KB
testcase_12 AC 27 ms
5,292 KB
testcase_13 AC 41 ms
5,492 KB
testcase_14 AC 17 ms
5,432 KB
testcase_15 AC 65 ms
5,788 KB
testcase_16 AC 62 ms
5,828 KB
testcase_17 AC 67 ms
5,892 KB
testcase_18 AC 66 ms
5,884 KB
testcase_19 AC 67 ms
5,948 KB
testcase_20 AC 68 ms
5,840 KB
testcase_21 AC 65 ms
5,844 KB
testcase_22 AC 68 ms
5,920 KB
testcase_23 AC 68 ms
5,928 KB
testcase_24 AC 68 ms
5,952 KB
testcase_25 AC 68 ms
5,856 KB
testcase_26 AC 69 ms
5,864 KB
testcase_27 AC 75 ms
5,852 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <iostream>
using namespace std;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    int a[200005];
    P p[200005];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        p[i] = P(a[i], i);
    }
    sort(p, p + n);
    bool b[200005];
    for(int i = 0; i < n; i++) b[i] = true;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(b[p[i].second]){
            ans++;
            if(p[i].second) b[p[i].second - 1] = false;
        }
    }
    cout << ans << endl;
}
0