結果
問題 | No.318 学学学学学 |
ユーザー | fura |
提出日時 | 2020-10-19 03:14:51 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 147 ms / 2,000 ms |
コード長 | 968 bytes |
コンパイル時間 | 2,581 ms |
コンパイル使用メモリ | 210,188 KB |
実行使用メモリ | 15,580 KB |
最終ジャッジ日時 | 2023-09-28 12:18:36 |
合計ジャッジ時間 | 7,777 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 9 ms
4,472 KB |
testcase_01 | AC | 19 ms
5,512 KB |
testcase_02 | AC | 23 ms
5,876 KB |
testcase_03 | AC | 14 ms
5,096 KB |
testcase_04 | AC | 19 ms
5,616 KB |
testcase_05 | AC | 145 ms
15,560 KB |
testcase_06 | AC | 107 ms
9,908 KB |
testcase_07 | AC | 87 ms
8,052 KB |
testcase_08 | AC | 70 ms
7,524 KB |
testcase_09 | AC | 54 ms
6,416 KB |
testcase_10 | AC | 37 ms
5,212 KB |
testcase_11 | AC | 147 ms
15,580 KB |
testcase_12 | AC | 87 ms
9,916 KB |
testcase_13 | AC | 67 ms
8,112 KB |
testcase_14 | AC | 55 ms
6,940 KB |
testcase_15 | AC | 44 ms
5,948 KB |
testcase_16 | AC | 32 ms
5,156 KB |
testcase_17 | AC | 62 ms
9,844 KB |
testcase_18 | AC | 55 ms
9,844 KB |
testcase_19 | AC | 61 ms
9,912 KB |
testcase_20 | AC | 27 ms
5,152 KB |
testcase_21 | AC | 2 ms
4,380 KB |
testcase_22 | AC | 2 ms
4,380 KB |
testcase_23 | AC | 1 ms
4,376 KB |
testcase_24 | AC | 2 ms
4,376 KB |
testcase_25 | AC | 1 ms
4,376 KB |
testcase_26 | AC | 2 ms
4,380 KB |
testcase_27 | AC | 2 ms
4,380 KB |
testcase_28 | AC | 2 ms
4,376 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; const int INF=1<<29; class segment_tree_dual{ int n; vector<int> seg; void chmax(int l,int r,int a,int b,int u,int x){ if(l<=a && b<=r){ seg[u]=max(seg[u],x); return; } int c=(a+b+1)/2; if(l<c && a<r) chmax(l,r,a,c,2*u ,x); if(l<b && c<r) chmax(l,r,c,b,2*u+1,x); } public: segment_tree_dual(int N){ for(n=1;n<N;n*=2); seg.assign(2*n,-INF); } void chmax(int l,int r,int x){ chmax(l,r,0,n,1,x); } int get(int u){ u+=n; int res=seg[u]; for(u/=2;u>=1;u/=2) res=max(res,seg[u]); return res; } }; int main(){ int n; scanf("%d",&n); vector<int> a(n); rep(i,n) scanf("%d",&a[i]); map<int,vector<int>> f; rep(i,n) f[a[i]].emplace_back(i); segment_tree_dual ST(n); for(auto [x,v]:f){ int l=INF,r=-INF; for(auto i:v){ l=min(l,i); r=max(r,i+1); } ST.chmax(l,r,x); } rep(i,n) printf("%d%c",ST.get(i),i<n-1?' ':'\n'); return 0; }