結果

問題 No.711 競技レーティング単調増加
ユーザー kimiyuki
提出日時 2018-06-30 01:48:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 520 bytes
コンパイル時間 2,118 ms
コンパイル使用メモリ 196,900 KB
最終ジャッジ日時 2025-01-06 11:47:34
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < int(n); ++ (i))
using namespace std;

int main() {
    // input
    int n; cin >> n;
    vector<int> a(n);
    REP (i, n) cin >> a[i];

    // solve
    REP (i, n) a[i] -= 1;
    multiset<int> dp;
    int shift = 0;
    for (int a_i : a) {
        auto it = dp.lower_bound(a_i);
        if (it != dp.end()) {
            dp.erase(it);
            ++ shift;
        }
        dp.insert(a_i);
    }

    // output
    cout << shift << endl;
    return 0;
}
0