結果

問題 No.318 学学学学学
ユーザー 37kt_37kt_
提出日時 2016-04-20 11:21:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 798 bytes
コンパイル時間 1,515 ms
コンパイル使用メモリ 166,804 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-04-15 03:50:49
合計ジャッジ時間 7,049 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
6,940 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

const int B = 100;
int n;
int a[100000];
int b[1000];
map<int, int> mn, mx;

int main(){
  cin >> n;
  for (int i = 0; i < n; i++){
    int x;
    cin >> x;
    if (!mn.count(x)) mn[x] = mx[x] = i;
    else mn[x] = min(mn[x], i), mx[x] = max(mx[x], i);
  }
  for (auto p : mn){
    int l = mn[p.first], r = mx[p.first] + 1, x = p.first;
    if (l / B == r / B){
      for (int i = l; i < r; i++){
        a[i] = x;
      }
    }
    else {
      for (int i = l; i < (l / B + 1) * B; i++){
        a[i] = x;
      }
      for (int i = r / B * B; i < r; i++){
        a[i] = x;
      }
      for (int i = (l / B + 1) * B; i < r / B; i++){
        b[i] = x;
      }
    }
  }
  for (int i = 0; i < n; i++){
    cout << max(a[i], b[i / B]) << endl;
  }
}
0