# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
467067 | 2021-08-21T15:09:27 Z | mtxas | Exam (eJOI20_exam) | C++14 | 1000 ms | 1144 KB |
#include <bits/stdc++.h> #define ll long long #define vi vector<int> #define vll vector<ll> #define pb push_back #define mfsadfp make_pair #define pii pair<int, int> #define pll pair<ll, ll> #define fi first #define se second #define mii map<int, int> #define all(a) a.begin(), a.end() #define _fre() freopen("input.txt", "r", stdin) #define turbo() cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false) #define sz(x) ((int)x.size()) #define _for(a, b, c) for(int (a) = (b); (a) < (c); (a)++) #define _foreq(a, b, c) for(int (a) = (b); (a) <= (c); (a)++) #define _forneq(a, b, c) for(int (a) = (b); (a) >= (c); (a)--) #define _forn(a, b, c) for(int (a) = (b); (a) > (c); (a)--) using namespace std; #define int ll /*********************************************************************************** STRUCTS ************************************************************************************/ /*********************************************************************************** VARIABLES ************************************************************************************/ const int maxn = 1e5+1; int n; int a[maxn], b[maxn]; int dp[maxn]; /*********************************************************************************** FUNCTIONS ************************************************************************************/ int pass(int l, int r){ int mx = 0; _foreq(i, l, r) mx = max(mx, a[i]); int ans = 0; _foreq(i, l, r) ans += (mx == b[i]); return ans; } /*********************************************************************************** MAIN ************************************************************************************/ signed main(){ // _fre(); turbo(); cin>>n; _foreq(i, 1,n) cin>>a[i]; _foreq(i, 1, n) cin>>b[i]; _foreq(i, 1, n){ _foreq(x, 0, i-1) dp[i] = max(dp[i], dp[x] + pass(x+1, i)); } cout<<dp[n]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 0 ms | 320 KB | Output is correct |
5 | Incorrect | 0 ms | 332 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 320 ms | 364 KB | Output is correct |
2 | Execution timed out | 1073 ms | 1144 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 204 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1083 ms | 508 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 0 ms | 320 KB | Output is correct |
5 | Incorrect | 0 ms | 332 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 316 KB | Output is correct |
4 | Correct | 0 ms | 320 KB | Output is correct |
5 | Incorrect | 0 ms | 332 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |