Submission #599891

#TimeUsernameProblemLanguageResultExecution timeMemory
599891starchanBaloni (COCI15_baloni)C++17
100 / 100
1072 ms59448 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define in pair<int, int> #define f first #define s second #define pb push_back #define pob pop_back #define INF (int)1e17 #define MX (int)3e5+5 #define fast() ios_base::sync_with_stdio(false); cin.tie(NULL) set<in> cool; signed main() { fast(); int n; cin >> n; for(int i = 1; i <= n; i++) { int x; cin >> x; cool.insert({-x, i}); } int ans = 0; while(cool.size()) { ans++; in fine = *cool.begin(); int curr = fine.f; int index = fine.s; cool.erase(cool.begin()); while(true) { if(cool.empty()) break; auto it = cool.lower_bound({curr+1, index}); if(it == cool.end()) break; if((*it).f == curr+1) { curr = (*it).f; index = (*it).s; cool.erase(it); } else break; } } cout << ans; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...