結果
問題 |
No.318 学学学学学
|
ユーザー |
|
提出日時 | 2024-06-12 19:09:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 171 ms / 2,000 ms |
コード長 | 942 bytes |
コンパイル時間 | 4,737 ms |
コンパイル使用メモリ | 261,356 KB |
最終ジャッジ日時 | 2025-02-21 21:20:09 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using ll = long long; const ll INF = 1e18; const ll ID = 1e18; ll op(ll a, ll b){ return max(a, b); } ll e(){ return -INF; } ll mapping(ll f, ll x){ if(f==ID) return x; return f; } ll composition(ll f, ll g){ if(f==ID) return g; return f; } ll id(){ return ID; } int N; vector<ll> A; void solve(){ map<int, vector<int>> mpv; for(int i = 0;i<N;++i){ mpv[A[i]].push_back(i); } lazy_segtree<ll, op, e,ll,mapping, composition, id> seg(A); for(auto [k, v]: mpv){ vector<int> idx; for(auto i: v){ idx.push_back(i); } sort(idx.begin(), idx.end()); if(idx.empty())continue; seg.apply(idx[0], idx.back()+1, k); } for(int i = 0;i<N;i++){ cout<<seg.get(i)<<" "; } cout<<endl; } signed main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin >> N; A.resize(N); for(int i=0; i<N; ++i) cin >> A[i]; solve(); }