結果

問題 No.1438 Broken Drawers
ユーザー HaaHaa
提出日時 2021-03-26 21:32:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 1,662 ms
コンパイル使用メモリ 174,212 KB
実行使用メモリ 9,444 KB
最終ジャッジ日時 2023-08-19 07:33:42
合計ジャッジ時間 4,237 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 56 ms
9,320 KB
testcase_07 AC 55 ms
9,444 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 26 ms
5,552 KB
testcase_13 AC 42 ms
6,748 KB
testcase_14 AC 19 ms
4,704 KB
testcase_15 AC 63 ms
8,748 KB
testcase_16 AC 64 ms
8,644 KB
testcase_17 AC 65 ms
9,060 KB
testcase_18 AC 67 ms
9,044 KB
testcase_19 AC 68 ms
9,168 KB
testcase_20 AC 68 ms
9,112 KB
testcase_21 AC 68 ms
9,120 KB
testcase_22 AC 70 ms
9,324 KB
testcase_23 AC 71 ms
9,388 KB
testcase_24 AC 73 ms
9,440 KB
testcase_25 AC 71 ms
9,316 KB
testcase_26 AC 71 ms
9,440 KB
testcase_27 AC 71 ms
9,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=998244353;
constexpr ll INF=2e18;

int main(){
    int n; cin >> n;
    VI a(n); REP(i,n) cin >> a[i];
    vector<P> p(n); REP(i,n) p[i]={a[i],i};
    sort(ALL(p));
    VI f(n,0);
    int ans=0;
    REP(i,n){
        if(p[i].second==n-1||!f[p[i].second+1]){
            ans++;
            f[p[i].second]=1;
        }
    }
    cout << ans << endl;
    return 0;
}
0