結果

問題 No.1438 Broken Drawers
ユーザー milanis48663220milanis48663220
提出日時 2021-03-26 21:25:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 1,067 bytes
コンパイル時間 1,013 ms
コンパイル使用メモリ 103,964 KB
実行使用メモリ 5,496 KB
最終ジャッジ日時 2023-08-19 07:01:08
合計ジャッジ時間 3,093 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 25 ms
5,496 KB
testcase_07 AC 24 ms
5,424 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,376 KB
testcase_12 AC 16 ms
4,376 KB
testcase_13 AC 23 ms
4,380 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 AC 38 ms
5,112 KB
testcase_16 AC 37 ms
5,092 KB
testcase_17 AC 39 ms
5,076 KB
testcase_18 AC 40 ms
5,348 KB
testcase_19 AC 41 ms
5,428 KB
testcase_20 AC 40 ms
5,368 KB
testcase_21 AC 39 ms
5,420 KB
testcase_22 AC 40 ms
5,456 KB
testcase_23 AC 41 ms
5,368 KB
testcase_24 AC 41 ms
5,420 KB
testcase_25 AC 40 ms
5,444 KB
testcase_26 AC 41 ms
5,488 KB
testcase_27 AC 41 ms
5,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;
using P = pair<int, int>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> a(n);
    vector<P> p(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        p[i] = P(a[i], i);
    }
    vector<bool> used(n);
    sort(p.begin(), p.end());
    int ans = 0;
    for(auto [x, i]: p){
        if(i == n-1 || !used[i+1]){
            ans++;
            used[i] = true;
        }
    }
    cout << ans << endl;
}
0