제출 #944495

#제출 시각아이디문제언어결과실행 시간메모리
944495vladiliusStone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<int> a(n + 1); for (int i = 1; i <= n; i++){ cin>>a[i]; } map<int, int> mp; vector<int> p(n + 1); for (int i = 1; i <= n; i++){ if (mp.find(a[i]) != mp.end()){ p[i] = mp[a[i]]; } mp[a[i]] = i; } int r = 0; for (int i = 1; i <= n; i++){ if (p[i] > r){ for (int j = p[i]; j < i; j++){ a[j] = a[i]; } r = i; } } for (int i = 1; i <= n; i++){ cout<<a[i]<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...