結果

問題 No.318 学学学学学
ユーザー kura197kura197
提出日時 2022-01-08 11:00:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 1,307 bytes
コンパイル時間 2,855 ms
コンパイル使用メモリ 207,700 KB
実行使用メモリ 22,144 KB
最終ジャッジ日時 2024-04-26 19:13:33
合計ジャッジ時間 7,526 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
5,248 KB
testcase_01 AC 34 ms
6,632 KB
testcase_02 AC 38 ms
7,296 KB
testcase_03 AC 26 ms
6,016 KB
testcase_04 AC 32 ms
6,656 KB
testcase_05 AC 224 ms
22,144 KB
testcase_06 AC 162 ms
15,872 KB
testcase_07 AC 148 ms
13,568 KB
testcase_08 AC 135 ms
12,032 KB
testcase_09 AC 121 ms
10,752 KB
testcase_10 AC 105 ms
9,600 KB
testcase_11 AC 224 ms
22,016 KB
testcase_12 AC 186 ms
15,744 KB
testcase_13 AC 158 ms
13,824 KB
testcase_14 AC 130 ms
12,160 KB
testcase_15 AC 113 ms
10,752 KB
testcase_16 AC 91 ms
9,728 KB
testcase_17 AC 136 ms
15,744 KB
testcase_18 AC 124 ms
15,744 KB
testcase_19 AC 133 ms
15,744 KB
testcase_20 AC 72 ms
9,600 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define MOD(a, m) ((a % m + m) % m)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;


int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for(auto& a : A) cin >> a;

    map<ll, int, greater<ll>> left, right;
    auto update_left = [&](ll key, int val){
        if(left.count(key) == 0) left[key] = val;
        else chmin(left[key], val);
    };
    REP(i,N){
        update_left(A[i], i);
        right[A[i]] = i;
    }

    vector<ll> B(N);
    set<int> se;
    REP(i,N) se.insert(i);
    for(auto& [a, L] : left){
        auto R = right[a];
        int idx = L;
        while(1){
            auto iter = se.lower_bound(idx);
            if(iter == se.end()) break;
            if(*iter > R) break;
            idx = *iter;
            B[idx] = a;
            se.erase(iter);
            idx++;
        }
    }

    for(auto& b : B) cout << b << " ";
    cout << endl;
    return 0;
}
0