Submission #1120039

#TimeUsernameProblemLanguageResultExecution timeMemory
1120039sunboiStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
537 ms14480 KiB
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); map<int, int> remaining; for (int i = 0; i < n; i++) { cin >> a[i]; remaining[a[i]]++; } int j = 0; for (int i = 0; i < n - 1; i++){ j = i + 1; remaining[a[i]]--; if (remaining[a[i]] > 0){ while(j < n && a[j] != a[i]){ remaining[a[j]]--; a[j] = a[i]; j++; } } i = j - 1; } for (int i = 0; i < n; i++){ cout << a[i] << endl; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...