Submission #983440

#TimeUsernameProblemLanguageResultExecution timeMemory
983440IUA_HasinStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
183 ms20048 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define endl "\n" using namespace std; int main(){ #if __has_include("LOCAL.hh") #include "LOCAL.hh" #endif #ifdef LOCAL freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); using namespace std::chrono; cout << fixed << setprecision(9); auto begin = steady_clock::now(); #else std::ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); #endif ll n; cin>>n; ll arr[n]; map<ll, ll> lastind; for(int i=0; i<n; i++){ cin>>arr[i]; lastind[arr[i]] = i; } ll ans[n]; ll l = 0; while(l<n){ ll temp = arr[l]; ll last = lastind[temp]; for(int i=l; i<=last; i++){ ans[i] = temp; } l = last+1; } for(int i=0; i<n; i++){ cout << ans[i] << endl; } #ifdef LOCAL auto end = steady_clock::now(); cout << "\nTime : " << (ld)duration_cast<nanoseconds> (end - begin).count()/1000000000 << "s" << endl; #endif return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...