結果

問題 No.1734 Decreasing Elements
ユーザー りあんりあん
提出日時 2021-11-05 22:13:46
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 751 ms / 3,000 ms
コード長 1,137 bytes
コンパイル時間 2,582 ms
コンパイル使用メモリ 216,816 KB
実行使用メモリ 7,788 KB
最終ジャッジ日時 2023-08-06 10:05:35
合計ジャッジ時間 9,509 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 35 ms
6,776 KB
testcase_08 AC 33 ms
6,732 KB
testcase_09 AC 22 ms
6,672 KB
testcase_10 AC 31 ms
6,704 KB
testcase_11 AC 56 ms
6,932 KB
testcase_12 AC 27 ms
5,136 KB
testcase_13 AC 52 ms
6,696 KB
testcase_14 AC 151 ms
7,360 KB
testcase_15 AC 88 ms
7,112 KB
testcase_16 AC 171 ms
7,472 KB
testcase_17 AC 180 ms
7,480 KB
testcase_18 AC 182 ms
7,460 KB
testcase_19 AC 734 ms
4,780 KB
testcase_20 AC 751 ms
4,780 KB
testcase_21 AC 687 ms
7,652 KB
testcase_22 AC 677 ms
7,788 KB
testcase_23 AC 372 ms
4,376 KB
testcase_24 AC 182 ms
4,376 KB
testcase_25 AC 430 ms
5,628 KB
testcase_26 AC 205 ms
5,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

const int M = 998244353;
const long long LM = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    // n = 200000;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        // a[i] = i + 1;
        cin >> a[i];
    }
    vector<vector<int>> vv;
    int SQ = 500;

    vector<int> v = { 0, 200010 };
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (auto& x : vv) {
            a[i] -= *prev(upper_bound(x.begin(), x.end(), a[i]));
        }
        a[i] -= *prev(upper_bound(v.begin(), v.end(), a[i]));
        if (a[i] > 0) {
            ++ans;
            vector<int> nex;
            for (int j = 0; j < (int)v.size(); ++j) {
                nex.push_back(v[j]);
                if (j + 1 < (int)v.size() && v[j] + a[i] < v[j + 1]) {
                    nex.push_back(v[j] + a[i]);
                }
            }
            v = nex;
        }
        if ((i + 1) % SQ == 0) {
            vv.push_back(v);
            v = { 0, 200010 };
        }
    }
    cout << ans << '\n';
    return 0;
}

0