제출 #768877

#제출 시각아이디문제언어결과실행 시간메모리
768877LucaLucaMFinancial Report (JOI21_financial)C++17
12 / 100
32 ms8796 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n, d; cin >> n >> d; vector<int>dp(n + 1, 0); vector<int>suff(n + 2, 0); vector<int> a(n + 1); for (int i=1; i<=n; i++) cin >> a[i]; stack<int>st; vector<int>nxt(n + 1, 0); for (int i=n; i>0; i--) { while (!st.empty() && a[i] >= a[st.top()]) st.pop(); nxt[i] = (st.empty()? n + 1 : st.top()); st.push(i); } for (int i=n; i>0; i--) { suff[i] = max(suff[i+1], a[i]); dp[i] = dp[nxt[i]] + 1; } cout << *max_element(dp.begin(), dp.end()); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...