結果
| 問題 | No.318 学学学学学 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-01-18 18:11:01 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 154 ms / 2,000 ms |
| コード長 | 686 bytes |
| 記録 | |
| コンパイル時間 | 4,207 ms |
| コンパイル使用メモリ | 349,016 KB |
| 実行使用メモリ | 13,312 KB |
| 最終ジャッジ日時 | 2026-01-18 18:11:12 |
| 合計ジャッジ時間 | 9,201 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#include<atcoder/lazysegtree>
using ll=long long;
int main(){
ll N;cin>>N;
vector<ll> A(N);
for(auto&a:A)cin>>a;
map<ll,pair<ll,ll>> mp;
for(ll i=0;i<N;i++){
if(!mp.contains(A[i])) mp[A[i]]={i,i};
else{
mp[A[i]]={min(mp[A[i]].first,i),max(i,mp[A[i]].second)};
}
}
atcoder::lazy_segtree<ll,
[](ll x,ll y){return max(x,y);},
[]{return 0;},
ll,
[](ll f,ll x){return (f==-1?x:f);},
[](ll f,ll g){return (f==-1?g:f);},
[]{return -1;}> seg(A);
for(auto[a,tmp]:mp){
auto[l,r]=tmp;
seg.apply(l,r+1,a);
}
for(int i=0;i<N;i++) cout<<seg.prod(i,i+1)<<' ';
}