Submission #916476

#TimeUsernameProblemLanguageResultExecution timeMemory
916476Darren0724Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
350 ms16528 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(),x.end() #define abcorz ios_base::sync_with_stdio(false);cin.tie(0); int32_t main(){ abcorz; int n;cin>>n; vector<int> v(n); vector<int> a[n]; vector<int> t; for(int i=0;i<n;i++){ cin>>v[i]; t.push_back(v[i]); } sort(all(t)); t.resize(unique(all(t))-t.begin()); for(int i=0;i<n;i++){ v[i]=lower_bound(all(t),v[i])-t.begin(); a[v[i]].push_back(i); } int i=0; while(i<n){ int sz=a[v[i]].size(); if(sz>1){ for(int j=i;j<a[v[i]][sz-1];j++){ v[j]=v[i]; } i=a[v[i]][sz-1]; } i++; } for(int i=0;i<n;i++){ cout<<t[v[i]]<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...