# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
440446 |
2021-07-02T09:55:27 Z |
prvocislo |
Exam (eJOI20_exam) |
C++17 |
|
214 ms |
13880 KB |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<int> a(n), b(n);
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) cin >> b[i];
vector<vector<int> > v(n, vector<int>(2, -1));
for (int it = 0; it < 2; it++)
{
map<int, int> m;
vector<pair<int, int>> stk; // {hodnota, index}
for (int k = 0; k < n; k++)
{
int i = it ? n - k - 1 : k;
while (!stk.empty() && a[i] > stk.back().first)
m[stk.back().first] = -1, stk.pop_back();
stk.push_back({a[i], i}); m[a[i]] = i;
if (m.count(b[i]) && m[b[i]] != -1)
v[i][it] = m[b[i]];
}
}
vector<int> u;
for (int i = 0; i < n; i++)
{
if (v[i][1] != -1) u.push_back(v[i][1]);
if (v[i][0] != -1 && v[i][0] != v[i][1]) u.push_back(v[i][0]);
}
vector<int> l;
for (int i : u)
{
int id = upper_bound(l.begin(), l.end(), i) - l.begin();
if (id == l.size()) l.push_back(i);
else l[id] = i;
}
cout << l.size() << "\n";
return 0;
}
Compilation message
exam.cpp: In function 'int main()':
exam.cpp:39:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | if (id == l.size()) l.push_back(i);
| ~~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
220 KB |
Output is correct |
2 |
Correct |
0 ms |
220 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
220 KB |
Output is correct |
6 |
Correct |
1 ms |
220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
10 ms |
2272 KB |
Output is correct |
3 |
Correct |
87 ms |
11848 KB |
Output is correct |
4 |
Correct |
34 ms |
8752 KB |
Output is correct |
5 |
Correct |
158 ms |
13196 KB |
Output is correct |
6 |
Correct |
29 ms |
7680 KB |
Output is correct |
7 |
Correct |
41 ms |
8732 KB |
Output is correct |
8 |
Correct |
129 ms |
11468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
476 KB |
Output is correct |
4 |
Correct |
5 ms |
860 KB |
Output is correct |
5 |
Correct |
5 ms |
988 KB |
Output is correct |
6 |
Correct |
5 ms |
984 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
860 KB |
Output is correct |
2 |
Correct |
62 ms |
5412 KB |
Output is correct |
3 |
Correct |
204 ms |
12420 KB |
Output is correct |
4 |
Correct |
214 ms |
13144 KB |
Output is correct |
5 |
Correct |
144 ms |
13880 KB |
Output is correct |
6 |
Correct |
153 ms |
13036 KB |
Output is correct |
7 |
Correct |
130 ms |
13624 KB |
Output is correct |
8 |
Correct |
204 ms |
12424 KB |
Output is correct |
9 |
Correct |
193 ms |
12352 KB |
Output is correct |
10 |
Correct |
116 ms |
12860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
220 KB |
Output is correct |
2 |
Correct |
0 ms |
220 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
220 KB |
Output is correct |
6 |
Correct |
1 ms |
220 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
220 KB |
Output is correct |
2 |
Correct |
0 ms |
220 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
0 ms |
328 KB |
Output is correct |
5 |
Correct |
1 ms |
220 KB |
Output is correct |
6 |
Correct |
1 ms |
220 KB |
Output is correct |
7 |
Correct |
1 ms |
328 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
476 KB |
Output is correct |
10 |
Correct |
5 ms |
860 KB |
Output is correct |
11 |
Correct |
5 ms |
988 KB |
Output is correct |
12 |
Correct |
5 ms |
984 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
204 KB |
Output is correct |
18 |
Correct |
1 ms |
344 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
1 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
332 KB |
Output is correct |
22 |
Correct |
1 ms |
332 KB |
Output is correct |
23 |
Correct |
3 ms |
716 KB |
Output is correct |
24 |
Correct |
3 ms |
716 KB |
Output is correct |
25 |
Correct |
3 ms |
708 KB |
Output is correct |
26 |
Correct |
4 ms |
676 KB |
Output is correct |
27 |
Correct |
3 ms |
596 KB |
Output is correct |
28 |
Correct |
6 ms |
880 KB |
Output is correct |
29 |
Correct |
4 ms |
800 KB |
Output is correct |
30 |
Correct |
4 ms |
860 KB |
Output is correct |
31 |
Correct |
5 ms |
852 KB |
Output is correct |
32 |
Correct |
6 ms |
860 KB |
Output is correct |