# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1157938 | SmuggingSpun | Stone Arranging 2 (JOI23_ho_t1) | C++20 | 216 ms | 13388 KiB |
#include<bits/stdc++.h>
#define taskname "A"
using namespace std;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n;
cin >> n;
vector<pair<int, int>>ans;
map<int, bool>cnt;
for(int _ = 0; _ < n; _++){
int x;
cin >> x;
if(cnt[x]){
int sum = 1;
while(ans.back().first != x){
cnt[ans.back().first] = false;
sum += ans.back().second;
ans.pop_back();
}
ans.back().second += sum;
}
else{
ans.emplace_back(x, 1);
cnt[x] = true;
}
}
for(auto& [u, v] : ans){
for(int i = 0; i < v; i++){
cout << u << "\n";
}
}
}
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... |