Submission #260153

#TimeUsernameProblemLanguageResultExecution timeMemory
260153sckmdBaloni (COCI15_baloni)C++14
0 / 100
81 ms131076 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 1000005 queue <int> ids[MAXN]; void go(int height,int prev) { if(!ids[height].size())return ; int idx = ids[height].front(); if(idx < prev)return ; ids[height].pop(); go(height-1,idx); } int solve() { int ans = 0; for(int height = MAXN-1; height > 0;) { if(!ids[height].size()){height--;continue;} go(height,-1); ans++; } return ans; } int main() { ios_base::sync_with_stdio(false); int n; cin >> n; for(int i = 1; i <= n; i++) { int h; cin >> h; ids[h].push(i); } cout << solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...