제출 #810947

#제출 시각아이디문제언어결과실행 시간메모리
810947tkwiatkowskiStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
142 ms15204 KiB
#include <iostream> #include <deque> #include <map> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; map<int, int> cnt; deque<pair<int, int>> stones; for (int i = 0; i < n; ++i) { int a; cin >> a; pair<int, int> top = {a, 1}; if (cnt[a] > 0) { while (true) { auto [color, count] = stones.back(); stones.pop_back(); top.second += count; cnt[color] -= count; if (color == a) break; } } stones.push_back(top); cnt[a] += top.second; } for (auto [a, cnt] : stones) for (int i = 0; i < cnt; ++i) cout << a << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...