# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
433035 |
2021-06-18T18:29:25 Z |
Valaki2 |
Exam (eJOI20_exam) |
C++14 |
|
35 ms |
1492 KB |
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
vector<int> b;
void solve_bf() {
}
void solve_bequal() {
int x = b[1];
int last = 0;
bool ok = false;
int ans = 0;
a.push_back(x + 1);
for(int i = 1; i <= (n + 1); ++i) {
if(a[i] > x) {
if(ok) {
ans += i - last - 1;
ok = false;
}
last = i;
} else if(a[i] == x) {
ok = true;
}
}
cout << ans << "\n";
}
void solve_astrictlyincreasing() {
vector<int> ans(1 + n, 0);
vector<int> c = a;
for(int i = 1; i <= n; ++i) {
int l = i;
int cur = ans[i - 1];
if(a[i] == b[i]) ++cur;
ans[i] = cur;
for(int j = i - 1; j >= 1; --j) {
if(c[j] == b[j]) --cur;
if(a[i] == b[j]) ++cur;
if(ans[i] < cur) {
ans[i] = cur;
l = j;
}
}
for(int j = i - 1; j >= l; --j) {
c[j] = a[i];
}
}
cout << ans[n] << "\n";
}
void solve() {
cin >> n;
a.assign(1 + n, 0);
b.assign(1 + n, 0);
for(int i = 1; i <= n; ++i) cin >> a[i];
for(int i = 1; i <= n; ++i) cin >> b[i];
set<int> b_set;
for(int i = 1; i <= n; ++i) {
b_set.insert(b[i]);
}
/*if(n <= 10) {
solve_bf();
} else */if(b_set.size() == 1) {
solve_bequal();
} else {
solve_astrictlyincreasing();
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
5 ms |
460 KB |
Output is correct |
3 |
Correct |
18 ms |
1356 KB |
Output is correct |
4 |
Correct |
15 ms |
1484 KB |
Output is correct |
5 |
Correct |
35 ms |
1356 KB |
Output is correct |
6 |
Correct |
16 ms |
1484 KB |
Output is correct |
7 |
Correct |
16 ms |
1488 KB |
Output is correct |
8 |
Correct |
25 ms |
1492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
460 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 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |