Submission #768434

#TimeUsernameProblemLanguageResultExecution timeMemory
768434green_gold_dogStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
129 ms16688 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; template<typename T> bool assign_min(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<typename T> bool assign_max(T& a, T b) { if (a < b) { a = b; return true; } return false; } void solve() { ll n; cin >> n; vector<pair<ll, ll>> arr; set<ll> be; for (ll i = 0; i < n; i++) { ll x; cin >> x; if (be.find(x) != be.end()) { ll nc = 1; while (arr.back().first != x) { be.erase(arr.back().first); nc += arr.back().second; arr.pop_back(); } arr.back().second += nc; continue; } be.insert(x); arr.emplace_back(x, 1); } for (auto[x, c] : arr) { for (ll i = 0; i < c; i++) { cout << x << '\n'; } } } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...