# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
866609 | yeediot | Stone Arranging 2 (JOI23_ho_t1) | C++14 | 181 ms | 20660 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pb push_back
#define sz(x) (int)(x.size())
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define vi vector<int>
#define vp vector<pii>
#define vvi vector<vi>
//Don't open the standings during contests.
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
map<int,int>mp;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n;
cin>>n;
vector<pii>num;
for(int i=0;i<n;i++){
int x;
cin>>x;
if(mp[x]){
int sum=0;
while(num.back().F!=x){
sum+=num.back().S;
mp[num.back().F]--;
num.pop_back();
}
num.back().S+=sum+1;
}
else{
num.pb({x,1});
mp[x]=1;
}
}
for(auto j:num){
for(int i=0;i<j.S;i++){
cout<<j.F<<'\n';
}
}
}
/*
input:
*/
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |