結果

問題 No.318 学学学学学
ユーザー CleyLCleyL
提出日時 2021-12-10 10:06:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 1,276 bytes
コンパイル時間 3,092 ms
コンパイル使用メモリ 90,132 KB
実行使用メモリ 15,984 KB
最終ジャッジ日時 2023-09-25 04:20:32
合計ジャッジ時間 5,925 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,380 KB
testcase_01 AC 23 ms
5,568 KB
testcase_02 AC 28 ms
5,940 KB
testcase_03 AC 18 ms
5,008 KB
testcase_04 AC 24 ms
5,744 KB
testcase_05 AC 179 ms
15,960 KB
testcase_06 AC 125 ms
12,384 KB
testcase_07 AC 114 ms
10,664 KB
testcase_08 AC 94 ms
8,952 KB
testcase_09 AC 81 ms
7,540 KB
testcase_10 AC 67 ms
6,068 KB
testcase_11 AC 185 ms
15,984 KB
testcase_12 AC 121 ms
11,808 KB
testcase_13 AC 94 ms
9,804 KB
testcase_14 AC 79 ms
8,180 KB
testcase_15 AC 65 ms
7,404 KB
testcase_16 AC 53 ms
6,280 KB
testcase_17 AC 91 ms
12,640 KB
testcase_18 AC 87 ms
12,568 KB
testcase_19 AC 86 ms
13,072 KB
testcase_20 AC 36 ms
6,068 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
struct d{
  int i;
  int l,r;
  bool operator<(d &a){
    return i < a.i;
  }
};
int main(){
  int n;cin>>n;
  map<int,pair<int,int>> A;
  vector<int> Z(n);
  for(int i = 0; n > i; i++){
    int t;cin>>t;
    if(!A[t].first){
      A[t].first = i+1;
    }
    A[t].second = i+1;
    Z[i] = t;
  }
  vector<int> ret[n+1],ans(n);
  for(auto x: A){
    ret[x.second.first-1].push_back(x.first);
    ret[x.second.second].push_back(-x.first);
  }
  priority_queue<int> C;
  priority_queue<int> eraser;
  
  for(int i = 0; n > i; i++){
    for(int j = 0; ret[i].size() > j; j++){
      if(ret[i][j]>0){
        C.push(ret[i][j]);
      }else if(ret[i][j] < 0){
        eraser.push(-1*ret[i][j]);
      }
    }
    //cout << C.size() << endl;
    while(C.size() && eraser.size() && C.top() == eraser.top()){
      C.pop();
      eraser.pop();
    }
    // cout << i << " " << C.size() << " " << eraser.size();
    // if(C.size())cout << " C:" << C.top();
    // if(eraser.size())cout << " e:" << eraser.top();
    // cout << endl;
    ans[i] = C.top();
  }
  for(int i = 0; n > i; i++){
    cout << max(Z[i],ans[i]);
    if(i+1 != n)cout << " ";
  }
  cout << endl;
  

}
0