Submission #620025

#TimeUsernameProblemLanguageResultExecution timeMemory
620025gonzakia29Financial Report (JOI21_financial)C++17
0 / 100
142 ms5072 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){ cout << dp[i] << " "; maxi = max(maxi, dp[i]); } cout << endl << 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...