結果

問題 No.318 学学学学学
コンテスト
ユーザー しらっ亭
提出日時 2015-12-17 03:44:32
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 550 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,383 ms
コンパイル使用メモリ 190,220 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2026-03-06 20:49:44
合計ジャッジ時間 2,930 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define REP(i,n) for (int i = 0; i < (n); i++)
// -------------------------------------

typedef pair<int, int> PII;

int A[100001];

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

  map<int, int> m;
  REP(i, N) {
    int ai;
    scanf("%d", &ai);
    m[ai] = i;
    A[i] = ai;
  }

  set<int> s;
  REP(i, N) {
    if (i > 0) _P(" ");
    int ai = A[i];
    s.insert(ai);
    _P("%d", *s.rbegin());
    if (m[ai] == i) s.erase(ai);
  }
  _P("\n");

  return 0;
}
0