Submission #833268

#TimeUsernameProblemLanguageResultExecution timeMemory
833268vjudge1Exam (eJOI20_exam)C++17
0 / 100
16 ms340 KiB
#include <bits/stdc++.h> using namespace std; int n; int h[100005]; int t[100005]; int dp[100005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> h[i]; } for (int i = 0; i < n; i++) { cin >> t[i]; } // subtask 3 dp[n] = 0; for (int i = n - 1; i >= 0; i--) { int maxx = 0, cnt = 0; for (int j = i; j < n; j++) { if (t[j] > maxx) { maxx = t[j]; cnt = 1; } else if (t[j] == maxx) { cnt++; } dp[i] = max(dp[i], dp[j + 1] + (h[j] == maxx ? cnt : 0)); } } cout << dp[0] << '\n'; 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...