結果

問題 No.318 学学学学学
ユーザー ctyl_0ctyl_0
提出日時 2016-02-19 23:36:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 126 ms / 2,000 ms
コード長 1,534 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 95,548 KB
実行使用メモリ 9,412 KB
最終ジャッジ日時 2023-09-04 18:30:29
合計ジャッジ時間 3,994 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
4,380 KB
testcase_01 AC 17 ms
4,504 KB
testcase_02 AC 22 ms
4,668 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 19 ms
4,512 KB
testcase_05 AC 126 ms
9,320 KB
testcase_06 AC 115 ms
7,008 KB
testcase_07 AC 95 ms
6,412 KB
testcase_08 AC 75 ms
5,872 KB
testcase_09 AC 62 ms
5,352 KB
testcase_10 AC 44 ms
5,196 KB
testcase_11 AC 124 ms
9,412 KB
testcase_12 AC 81 ms
7,212 KB
testcase_13 AC 66 ms
6,300 KB
testcase_14 AC 55 ms
5,884 KB
testcase_15 AC 45 ms
5,332 KB
testcase_16 AC 31 ms
5,068 KB
testcase_17 AC 68 ms
7,220 KB
testcase_18 AC 45 ms
6,928 KB
testcase_19 AC 70 ms
6,916 KB
testcase_20 AC 29 ms
5,112 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 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";
}
template <typename T> inline void voutput(T v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}
// 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]);
    }
    
    voutput(B);
    
    return 0;
}
0