제출 #774767

#제출 시각아이디문제언어결과실행 시간메모리
774767vjudge1Stone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
276 ms21928 KiB
#include <bits/stdc++.h> using namespace std; const int N = 2e5+7; map <int, int> mp, mp2; int a[N], b[N]; int n; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; //cout << n << " MF\n"; for (int i = 1; i <= n; i++){ cin >> a[i]; mp[a[i]]++; mp2[a[i]] = max(mp2[a[i]], i); } for (int i = 1; i <= n; i++){ //cout << i << ' ' << n << " MF\n"; if (mp[a[i]] > 1 && i != mp2[a[i]]){ for (int j = i+1; j <= n; j++){ if (a[j] == a[i]){ i = j; break; } mp[a[i]]++; mp[a[j]]--; a[j] = a[i]; } i--; } } //cout << n << " MF\n"; 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...