Submission #619986

#TimeUsernameProblemLanguageResultExecution timeMemory
619986gonzakia29Financial Report (JOI21_financial)C++17
0 / 100
2379 ms6796 KiB
#include <iostream> using namespace std; int n, d; int nums[300010]; int dp[300010]; int mini[300000]; int maxi; int main(){ cin >> n >> d; for (int i = 0; i < n; ++i){ cin >> nums[i]; dp[i] = 1; mini[i] = 0; } mini[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] < mini[dp[i]]){ dp[i]++; } mini[dp[i]] = max(mini[dp[i]], nums[i]); } if (nums[i] == nums[i-1]){ dp[i] = dp[i-1]; } if (nums[i] > nums[i+1]){ while(nums[i] < mini[dp[i]]){ dp[i]++; } mini[dp[i]] = max(mini[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...