제출 #260157

#제출 시각아이디문제언어결과실행 시간메모리
260157sckmdBaloni (COCI15_baloni)C++14
100 / 100
1410 ms45720 KiB
#include <bits/stdc++.h> using namespace std; #define MAXN 1000005 typedef pair<int,int> pii; set <pii> st; void go(int height,int prev) { if(st.lower_bound({height,prev})==st.end())return ; auto it = st.lower_bound({height,prev}); pii x = *it; if(x.first != height)return ; if(x.second < prev)return ; st.erase(it); go(height-1,x.second); } int solve() { int ans = 0; for(int height = MAXN-1; height > 0;) { if(st.lower_bound({height,-1})==st.end()){height--;continue;} /*auto it = st.lower_bound({height,-1}); pii x = *it; if(x.first != height){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; st.insert({h,i}); } cout << solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...