結果

問題 No.318 学学学学学
ユーザー face4face4
提出日時 2019-01-29 13:04:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 982 ms
コンパイル使用メモリ 89,424 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-04-17 23:03:08
合計ジャッジ時間 5,351 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
5,248 KB
testcase_01 AC 29 ms
5,504 KB
testcase_02 WA -
testcase_03 AC 23 ms
5,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 135 ms
7,168 KB
testcase_08 AC 112 ms
6,144 KB
testcase_09 AC 93 ms
5,376 KB
testcase_10 AC 75 ms
5,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 105 ms
8,704 KB
testcase_18 AC 90 ms
8,704 KB
testcase_19 AC 102 ms
8,704 KB
testcase_20 WA -
testcase_21 AC 3 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<iostream>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;

    vector<int> a(n);
    map<int,int> l, r;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(l.count(a[i]) == 0)  l[a[i]] = i;
        r[a[i]] = i;
    }
    sort(a.rbegin(), a.rend());
    a.erase(unique(a.begin(), a.end()), a.end());

    vector<int> ans(n, 0);
    for(int val : a){
        int le = l[val], ri = r[val];
        
        int cur = l[val];
        while(cur <= ri && ans[cur] == 0)   ans[cur++] = val;
        cur = ri;
        while(cur >= le && ans[cur] == 0)   ans[cur--] = val;
    }

    for(int i = 0; i < n; i++)  cout << ans[i] << " \n"[i == n-1];

    return 0;
}
0