Submission #897148

#TimeUsernameProblemLanguageResultExecution timeMemory
897148LudisseyStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
50 ms8652 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int n; signed main() { // Input: ios::sync_with_stdio(false); cin.tie(nullptr); cin>>n; vector<pair<int,int>> a(n); vector<pair<int,int>> ainx(n,{0,-1}); for (int i = 0; i < n; i++) { cin >> ainx[i].first; a[i]={ainx[i].first,i}; } sort(a.begin(),a.end()); for (int i = 1; i < n; i++) { if(a[i].first==a[i-1].first){ ainx[a[i-1].second].second=a[i].second; } } int s=0; while(s<n) { if(ainx[s].second!=-1){ for (int i = s; i < ainx[s].second; i++) { cout << ainx[s].first << "\n"; } s=ainx[s].second; }else { cout << ainx[s].first << "\n"; s++; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...