Submission #1135489

#TimeUsernameProblemLanguageResultExecution timeMemory
1135489UnforgettableplStone Arranging 2 (JOI23_ho_t1)C++20
35 / 100
50 ms11660 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef double ld; const int INF = 1e10; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> arr(n); for(int&i:arr)cin>>i; set<int> arrnew; map<int,int> idx; for(int i=0;i<n;i++) { if(idx.contains(arr[i])) { while(*--arrnew.end()>idx[arr[i]])arrnew.erase(--arrnew.end()); } idx[arr[i]]=i+1; arrnew.insert(i+1); } auto iter = arrnew.begin(); int col = -1; for(int i=1;i<=n;i++) { if(iter!=arrnew.end() and *iter==i){col=arr[i-1];iter++;} cout << col << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...