結果

問題 No.318 学学学学学
ユーザー ctyl_0ctyl_0
提出日時 2016-02-19 23:02:36
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,437 bytes
コンパイル時間 1,041 ms
コンパイル使用メモリ 94,912 KB
実行使用メモリ 11,316 KB
最終ジャッジ日時 2023-10-23 18:35:16
合計ジャッジ時間 7,036 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
11,316 KB
testcase_01 AC 17 ms
4,680 KB
testcase_02 AC 20 ms
4,724 KB
testcase_03 AC 13 ms
4,480 KB
testcase_04 AC 18 ms
4,748 KB
testcase_05 AC 133 ms
9,460 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

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]);
        B[i] = *max_element(all(s));
        if (R[i]) s.erase(R[i]);
    }
    
    rep(i, N){
        if (i) cout << " " << B[i];
        else cout << B[i];
    }
    cout << endl;
    
    return 0;
}
0