結果

問題 No.1438 Broken Drawers
ユーザー zuminzumin
提出日時 2021-03-26 21:35:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 1,000 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 14,148 KB
最終ジャッジ日時 2023-08-19 07:39:57
合計ジャッジ時間 5,138 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 152 ms
13,936 KB
testcase_07 AC 132 ms
14,148 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 7 ms
4,384 KB
testcase_12 AC 59 ms
7,276 KB
testcase_13 AC 100 ms
9,908 KB
testcase_14 AC 39 ms
6,096 KB
testcase_15 AC 163 ms
12,996 KB
testcase_16 AC 166 ms
12,748 KB
testcase_17 AC 181 ms
13,468 KB
testcase_18 AC 172 ms
13,716 KB
testcase_19 AC 170 ms
13,712 KB
testcase_20 AC 172 ms
13,712 KB
testcase_21 AC 170 ms
13,336 KB
testcase_22 AC 174 ms
13,800 KB
testcase_23 AC 186 ms
13,844 KB
testcase_24 AC 178 ms
13,788 KB
testcase_25 AC 185 ms
13,844 KB
testcase_26 AC 184 ms
13,976 KB
testcase_27 AC 175 ms
13,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int n,ans=0;
    cin>>n;
    vector<int> a(n),used(n,0);
    map<int,int> place;

    for(int i=0;i<n;i++){
        cin>>a[i];
        place[a[i]]=i;
    }
    sort(a.begin(),a.end());

    for(int ai:a){
        if(used[place[ai]]) continue;
        int pi=place[ai];
        used[pi]=1;
        if(pi>0) used[pi-1]=1;
        ans++;
    }
    cout<<ans<<endl;

    return 0;
}
0