QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#419115 | #4191. Hectic Harbour II | zezoo050# | WA | 1ms | 3868kb | C++20 | 1.1kb | 2024-05-23 17:59:52 | 2024-05-23 17:59:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void tc() {
int n, s1, s2;
cin >> n >> s1 >> s2;
vector<int> a(s1);
for (int i = 0; i < s1; i++) {
cin >> a[i];
}
vector<int> b(s2);
for (int i = 0; i < s2; i++)cin >> b[i];
for (int i = s2 - 1; i >= 0; i--)
a.push_back(b[i]);
b.clear();
int z = -1;
for (int i = 0; i < a.size(); i++) {
if (a[i] == 0)z = i;
else if (z != -1)b.push_back(a[i]);
}
a.resize(z);
std::reverse(a.begin(), a.end());
auto lis = [](vector<int> a) -> int {
vector<int> v;
for (int i = 0; i < a.size(); i++) {
if (v.empty() || v.back() < a[i])
v.push_back(a[i]);
else
v[std::lower_bound(v.begin(), v.end(), a[i]) - v.begin()] = a[i];
}
return v.size();
};
cout << lis(a) + lis(b) << '\n';
}
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
// cin >> t;
while (t--) {
tc();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3868kb
input:
4 3 2 2 0 3 1 4
output:
3
result:
ok single line: '3'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3640kb
input:
6 4 3 2 4 0 1 6 3 5
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
11 2 10 3 9 11 5 6 0 1 7 4 8 10 2
output:
6
result:
ok single line: '6'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
3 2 2 3 2 0 1
output:
3
result:
ok single line: '3'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3676kb
input:
7 4 4 0 6 3 1 5 7 2 4
output:
3
result:
wrong answer 1st lines differ - expected: '2', found: '3'