# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
411589 | 2021-05-25T14:45:35 Z | aris12345678 | Exam (eJOI20_exam) | C++14 | 1000 ms | 3012 KB |
#include <bits/stdc++.h> using namespace std; const int mxN = 1e5+5; int a[mxN], b[mxN], dp[mxN]; bool sub2(int n) { for(int i = 1; i < n; i++) { if(b[i] != b[i-1]) return false; } return true; } int main() { int n; scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", &a[i]); for(int i = 0; i < n; i++) scanf("%d", &b[i]); if(sub2(n)) { int i = 0, j = 0, mx = 0, ans = 0; while(j < n) { if(a[j] > b[0] && mx == b[0]) ans += (j-i), mx = 0; while(a[j] > b[0]) j++, i = j; mx = max(mx, a[j++]); } if(mx == b[0]) ans += (j-i); printf("%d\n", ans); } else { int ans = 0; for(int mask = 0; mask < 1 << n; mask++) { int res = 0; map<int, int> left, right; for(int i = 0; i < n; i++) { left[b[i]]++; if(mask&(1 << i)) { for(int j = i+1; j < n; j++) { if(mask&(1 << j)) break; right[b[j]]++; } res += left[a[i]]+right[a[i]]; left.clear(); right.clear(); } } left.clear(); right.clear(); ans = max(ans, res); } printf("%d\n", ans); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 324 KB | Output is correct |
2 | Correct | 7 ms | 844 KB | Output is correct |
3 | Correct | 22 ms | 1984 KB | Output is correct |
4 | Correct | 25 ms | 1400 KB | Output is correct |
5 | Correct | 29 ms | 2996 KB | Output is correct |
6 | Correct | 19 ms | 1428 KB | Output is correct |
7 | Correct | 21 ms | 1488 KB | Output is correct |
8 | Correct | 31 ms | 3012 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 204 KB | Output is correct |
2 | Execution timed out | 1088 ms | 332 KB | Time limit exceeded |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 460 ms | 564 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Incorrect | 1 ms | 204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |