QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#419115#4191. Hectic Harbour IIzezoo050#WA 1ms3868kbC++201.1kb2024-05-23 17:59:522024-05-23 17:59:52

Judging History

你现在查看的是最新测评结果

  • [2024-05-23 17:59:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3868kb
  • [2024-05-23 17:59:52]
  • 提交

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'