제출 #774783

#제출 시각아이디문제언어결과실행 시간메모리
774783vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
4 ms3668 KiB
#include<bits/stdc++.h> using namespace std; int n, x; map<int,int>mp; int a[200001], c[200001], b[200001], cnt; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for(int i=0;i<n;i++) { cin >> a[i]; } for(int i=n-1;i>=0;i++) { if(mp[a[i]] == 0) { mp[a[i]] = i; c[i] = i; b[i] = i; } else { c[i] = i; b[i] = mp[a[i]]; mp[a[i]] = i; } } int p = 0; bool ck = false; while(p < n) { cnt = b[p] - c[p] + 1; if(!ck) { for(int i=1;i<=cnt;i++) { cout << a[p] << endl; } } else { for(int i=1;i<=cnt-1;i++) { cout << a[p] << endl; } } p += cnt; if(cnt > 1) { p -= 1; ck = true; } else { ck = false; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...