제출 #620026

#제출 시각아이디문제언어결과실행 시간메모리
620026gonzakia29Financial Report (JOI21_financial)C++17
0 / 100
2248 ms4564 KiB
#include <iostream> using namespace std; int n, d; int nums[300010]; int dp[300010]; int maxim[300000]; int maxi; int main(){ cin >> n >> d; for (int i = 0; i < n; ++i){ cin >> nums[i]; dp[i] = 1; maxim[i] = 0; } maxim[1] = nums[n-1]; for (int i = n-2; i >= 0; --i){ if (nums[i] < nums[i+1]){ dp[i] = dp[i+1]+1; while (nums[i] < maxim[dp[i]]){ dp[i]++; } maxim[dp[i]] = max(maxim[dp[i]], nums[i]); } if (nums[i] == nums[i-1]){ dp[i] = dp[i-1]; } if (nums[i] > nums[i+1]){ while(nums[i] < maxim[dp[i]]){ dp[i]++; } maxim[dp[i]] = max(maxim[dp[i]], nums[i]); } } for (int i = 0; i < n; ++i){ maxi = max(maxi, dp[i]); } cout << maxi; }
#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...