結果

問題 No.318 学学学学学
ユーザー ctyl_0ctyl_0
提出日時 2016-02-19 23:03:30
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 1,461 bytes
コンパイル時間 857 ms
コンパイル使用メモリ 94,744 KB
実行使用メモリ 9,396 KB
最終ジャッジ日時 2023-09-04 18:29:13
合計ジャッジ時間 4,173 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,376 KB
testcase_01 AC 18 ms
4,440 KB
testcase_02 AC 21 ms
4,496 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 19 ms
4,556 KB
testcase_05 AC 124 ms
9,332 KB
testcase_06 AC 112 ms
7,008 KB
testcase_07 AC 93 ms
6,248 KB
testcase_08 AC 76 ms
5,772 KB
testcase_09 AC 62 ms
5,088 KB
testcase_10 AC 44 ms
4,584 KB
testcase_11 AC 119 ms
9,396 KB
testcase_12 AC 79 ms
6,964 KB
testcase_13 AC 66 ms
6,156 KB
testcase_14 AC 54 ms
5,728 KB
testcase_15 AC 43 ms
5,096 KB
testcase_16 AC 30 ms
4,580 KB
testcase_17 AC 66 ms
6,960 KB
testcase_18 AC 44 ms
7,008 KB
testcase_19 AC 68 ms
6,932 KB
testcase_20 AC 28 ms
4,552 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1e9+7
#define inf 1<<32-1
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N;
    cin >> N;
    vector<int> A(N), L(N, -1), R(N, -1), B(N);
    rep(i, N){
        cin >> A[i];
    }
    
    set<int> s;
    rep(i, N){
        if (s.find(A[i]) == s.end()) {
            L[i] = A[i];
            s.insert(A[i]);
        }
    }
    s.erase(all(s));
    
    for (int i = N - 1; i >= 0; i--) {
        if (s.find(A[i]) == s.end()) {
            R[i] = A[i];
            s.insert(A[i]);
        }
    }
    s.erase(all(s));
    
    rep(i, N){
        if (L[i]) s.insert(L[i]);
        auto it = s.end();
        it--;
        B[i] = *it;
        if (R[i]) s.erase(R[i]);
    }
    
    rep(i, N){
        if (i) cout << " " << B[i];
        else cout << B[i];
    }
    cout << endl;
    
    return 0;
}
0