# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
554968 |
2022-04-29T18:38:39 Z |
Itamar |
Exam (eJOI20_exam) |
C++14 |
|
8 ms |
600 KB |
#include <map>
#include <iostream>
using namespace std;
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll,ll>
const int siz = 1e5;
int a[siz];
int b[siz];
int solve(int i, int j) {
int n = j - i + 1;
vi dp(n + 1, 1e9 + 1);
dp[0] = 0;
int max = 0;
for (int t = 0; t < n; t++) {
int x = b[t + i];
if (x > 1e9)
continue;
auto it = upper_bound(dp.begin(), dp.end(), x);
*it = x;
if (max < it - dp.begin()) {
max = it - dp.begin();
}
}
return max;
}
int main()
{
int n;
cin >> n;
set<int> s;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
a[i] = x;
s.insert(x);
}
for (int i = 0; i < n; i++) {
int x;
cin >> x;
b[i] = x;
if (b[i] < a[i] || s.find(x) == s.end())
b[i] = 2e9 - i;
}
int sum = 0;
int last = 0;
for (int i = 1; i < n; i++) {
if (a[i] < a[i - 1]) {
sum += solve(last, i - 1);
last = i;
}
}
sum+=solve(last, n - 1);
cout << sum;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
452 KB |
Output is correct |
4 |
Correct |
4 ms |
596 KB |
Output is correct |
5 |
Correct |
5 ms |
596 KB |
Output is correct |
6 |
Correct |
6 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
468 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
312 KB |
Output is correct |
5 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |