This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
//#define int long long
using namespace std;
using pii=pair<int, int>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
//using ll=long long;
#define loop(x,n) for(int x=0; x<n; x++)
#define loop1(x,n) for(int x=1; x<=n; x++)
#define loopr(x,n) for(int x=n; x-->0;)
#define F first
#define S second
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define all(v) begin(v), end(v)
#define UNTIE_IO ios_base::sync_with_stdio(0);cin.tie(0);
const int MAX=2e5+5;
const int INF=2e9;
const int MOD=998244353;
int N;
pii _c[MAX];
int c[MAX];
int m[MAX];
vector<int> p[MAX];
void solve(){
vector<int> v;
int lt;
loop1(i, N){
if (p[c[i]].size()){
lt = p[c[i]].back();
while (v.size()&&c[v.back()]!=c[i]){
p[c[v.back()]].pop_back();
v.pop_back();
}
}
p[c[i]].pb(i);
v.pb(i);
}
int idx=0;
loop1(i, N){
if (i>v[idx]) idx++;
cout << m[c[v[idx]]] << '\n';
}
}
signed main(){
UNTIE_IO;
cin>>N;
int x;
loop1(i, N){
cin>>x;
_c[i] = mp(x, i);
}
sort(_c+1, _c+1+N);
int lt=-1, idx=0;
loop1(i, N){
if (lt!=_c[i].first){
idx++;
lt = _c[i].first;
m[idx] = lt;
}
c[_c[i].second] = idx;
}
solve();
}
Compilation message (stderr)
Main.cpp: In function 'void solve()':
Main.cpp:35:9: warning: variable 'lt' set but not used [-Wunused-but-set-variable]
35 | int lt;
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |