Submission #964788

#TimeUsernameProblemLanguageResultExecution timeMemory
964788resfastStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
604 ms24456 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3") using namespace std; #define islam_zymchybekov void solve() #define ios ios::sync_with_stdio(false); cin.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define nl cout<<'\n'; #define int long long typedef vector<int> vi; typedef pair<int,int> pi; const int N=2e5+5; islam_zymchybekov{ int n; map<int,int>mx,mn; cin>>n; int x,a[n+1]{}; int j=0; vector<pair<int,pair<int,int>>>v; for(int i=1;i<=n;i++){ cin>>x; a[i]=x; mx[a[i]]=max(mx[a[i]],i); // if(mn[a[i]]==0)mn[a[i]]=i; } int d=0; for(int i=1;i<=n;i++){ if(mx[a[i]]!=0 && mx[a[i]]>d){ v.pb({i,{mx[a[i]],a[i]}}); d=mx[a[i]]; i=d; } } nl; // for(auto f:v){ // cout<<f.fr<<' '<<f.sc.fr<<' '<<f.sc.sc;nl; // } // /* for(int i=1;i<=n;i++){ if(i<v[j].fr)cout<<a[i]<<endl; else if(i>=v[j].fr && i<=v[j].sc.fr){ cout<<v[j].sc.sc<<endl; if(i==v[j].sc.fr)j++; } } // */ } main(){ ios; int T = 1; // cin >> T; while(T--){ solve(); } //cout<<fixed<<setprecision(10); //cerr<<"Time:"<<1000*((double)clock())/(double)CLOCKS_PER_SEC<<"ms\n";__int128 }

Compilation message (stderr)

Main.cpp:52:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 |  main(){
      |  ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...