Submission #464991

#TimeUsernameProblemLanguageResultExecution timeMemory
464991TeaTimeMoney (IZhO17_money)C++17
0 / 100
1 ms280 KiB
//#pragma GCC optimize("O3") //#pragma GCC target("avx2") #include <iostream> #include <vector> #include <string> #include <algorithm> #include <map> #include <set> #include <queue> #include <unordered_map> using namespace std; #define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); typedef long long ll; typedef long double ld; #define int ll const ll SZ = 1e6 + 10, INF = 1e9; ll n, m, q; vector<ll> vec; signed main() { fastInp; cin >> n; vec.resize(n); ll ans = 0; for (auto& c : vec) cin >> c; vector<ll> used(n + 1); for (int i = 0; i < n; i++) { //pos[vec[i] - 1] = i; vec[i]--; } multiset<pair<ll, ll>> er; for (int i = 0; i < n; i++) er.insert({ vec[i], i }); er.insert({ INF, INF }); used[n] = 1; while (vec.size()) { ans++; ll cur = vec.back(); vector<pair<ll, ll>> ltr; ltr.push_back({ cur, vec.size() - 1 }); vec.pop_back(); while (vec.size() > 0 && (*(++er.lower_bound(make_pair( vec.back(), vec.size() - 1 )))).first == cur) { ltr.push_back({ vec.back(), vec.size() - 1 }); cur = vec.back(); vec.pop_back(); } for (auto c : ltr) er.erase(er.find(c)); } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...