Submission #1116447

#TimeUsernameProblemLanguageResultExecution timeMemory
1116447heeyBaloni (COCI15_baloni)C++14
100 / 100
1523 ms12180 KiB
#include<bits/stdc++.h> using namespace std; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> h(n); for(int i = 0; i < n; i++) cin >> h[i]; vector<stack<int>> ss(1); for(int i = 0; i < n; i++){ int j = 0; while(!ss[j].empty() && ss[j].top() != h[i] + 1) j++; if(ss[j].empty()) { ss.push_back(stack<int>()); } ss[j].push(h[i]); } cout << ss.size() - 1<< '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...