# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1055467 | dpsaveslives | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 109 ms | 16120 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;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N; cin >> N;
vector<array<int,3>> vec;
multiset<int> ms;
for(int i = 0;i<N;++i){
int x; cin >> x;
if(ms.find(x) == ms.end()){
ms.insert(x);
vec.push_back({x,i,i});
continue;
}
ms.insert(x);
while(!vec.empty() && vec.back()[0] != x){
ms.erase(ms.find(vec.back()[0]));
vec.pop_back();
}
int ind = vec.back()[1];
ms.erase(ms.find(x)); vec.pop_back();
vec.push_back({x,ind,i});
}
for(int i = 0;i<vec.size();++i){
for(int j = vec[i][1];j<=vec[i][2];++j){
cout << vec[i][0] << "\n";
}
}
return 0;
}
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... |