제출 #805560

#제출 시각아이디문제언어결과실행 시간메모리
805560kirakaminski968Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
150 ms16772 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int N; cin >> N; vector<int> arr(N); for(int i = 0;i<N;++i) cin >> arr[i]; vector<array<int,3>> vec; multiset<int> alive; for(int i = 0;i<N;++i){ if(alive.find(arr[i]) == alive.end()){ //cout << i << "\n"; alive.insert(arr[i]); vec.push_back({i,i,arr[i]}); } else{ while(vec.back()[2] != arr[i] && !vec.empty()){ alive.erase(alive.find(vec.back()[2])); vec.pop_back(); } array<int,3> a = {0,i,arr[i]}; if(vec.size()){ a[0] = vec.back()[1]+1; } vec.push_back(a); alive.insert(arr[i]); } } for(auto x : vec){ //cout << x[0] << " " << x[1] << "\n"; for(int i = 0;i<=x[1]-x[0];++i){ cout << x[2] << "\n"; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...