제출 #906259

#제출 시각아이디문제언어결과실행 시간메모리
906259AlphaMale06Stone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
192 ms20052 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define yes cout << "YES\n" #define no cout << "NO\n" #define F first #define S second #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() #define int long long multiset<pair<int, int>> ms; void solve(){ int n; cin >> n; int a[n]; for(int i=0; i< n; i++){ cin >> a[i]; ms.insert({a[i], i}); } int ans[n]; for(int i=0; i< n; i++){ auto ptr = ms.lower_bound({a[i], i+1}); if(ptr!=ms.end() && (*ptr).F==a[i]){ int ind=(*ptr).S; for(int j=i; j<=ind; j++){ ans[j]=a[i]; ms.erase({a[j], j}); } i=ind-1; } else{ ans[i]=a[i]; } } for(int e : ans)cout << e << '\n'; cout << '\n'; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...