Submission #643022

#TimeUsernameProblemLanguageResultExecution timeMemory
643022ddy888Baloni (COCI15_baloni)C++17
100 / 100
170 ms57244 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #pragma GCC optimize("unroll-loops") using namespace std; using namespace __gnu_pbds; using ll = long long; #define pb push_back #define fi first #define si second #define ar array typedef pair<int,int> pi; typedef tuple<int,int,int> ti; template<typename T> bool chmin(T &a, T b){return (b < a) ? a = b, 1 : 0;} template<typename T> bool chmax(T &a, T b){return (b > a) ? a = b, 1 : 0;} template<class key, class value = null_type, class cmp = less<key> > using ordered_set = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>; mt19937 rng(chrono::system_clock::now().time_since_epoch().count()); void debug_out() {cerr<<endl;} template <typename Head, typename... Tail> void debug_out(Head _H, Tail... _T) {cerr<<" "<<to_string(_H);debug_out(_T...);} #define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__) const int MAXN = 1000010; int n; int arr[MAXN], f[MAXN]; set<int> pos[MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin.exceptions(ios::badbit | ios::failbit); cin >> n; for (int i = 1; i <= n; ++i) cin >> arr[i]; for (int i = n; i >= 1; --i) { int p = arr[i]-1; if ((int)pos[p].size()) { f[*pos[p].begin()] = 1; pos[p].erase(*pos[p].begin()); } pos[arr[i]].insert(i); } int ans = 0; for (int i = 1; i <= n; ++i) ans += (f[i]==0); cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...