QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#605898#1441. Special GamehackerzoeWA 1ms10296kbC++171.6kb2024-10-02 20:27:482024-10-02 20:27:50

Judging History

This is the latest submission verdict.

  • [2024-10-02 20:27:50]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 10296kb
  • [2024-10-02 20:27:48]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define plll pair<ll, pll>
#define x first
#define y second

int f(vector<int> a, vector<int> b){
    int k = a.size();
    if(k == 0) return 0;
    if(a[0] > b[k - 1]) return k;
    if(b[0] > a[k - 1]) return 0;

    int z = -2222, w = 2222;
    int q = 0;
    /*while(p < k){
        while(q != k - 1 && a[p] > b[q]){
            q ++;
        }
        if(p - q > z - w){
            z = p;
            w = q;
        }
        p ++;
    }*/
    
    for(int p = 0 ; p < k ; p ++){
        while(q != k - 1 && a[p] > b[q]){
            q ++;
        }
        if(p - q > z - w){
            z = p;
            w = q;
        }
    }

    /*for(int i = 0 ; i < k ; i ++){
        for(int j = 0 ; j < k ; j ++){
            if(a[i] < b[j] && i - j > z - w){
                z = i;
                w = j;
                break;
            }
        }
    }*/
    vector<int> c, d;
    for(int i = 0 ; i < k ; i ++){
        if(i != z) c.push_back(a[i]);
        if(i != w) d.push_back(b[i]);
    }
    return k - 1 - f(d, c);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    vector<int> a, b;
    for(int i = 0 ; i < n ; i ++){
        int data;
        cin >> data;
        a.push_back(data);
    }
    for(int i = 0 ; i < n ; i ++){
        int data;
        cin >> data;
        b.push_back(data);
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    cout << f(a, b);

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3864kb

input:

3
1 2 5
3 4 6

output:

1

result:

ok "1"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

2
4 3
1 2

output:

2

result:

ok "2"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

1
1
2

output:

0

result:

ok "0"

Test #4:

score: 0
Accepted
time: 1ms
memory: 3604kb

input:

9
2 12 10 3 4 7 17 14 16
6 1 13 11 9 15 18 8 5

output:

5

result:

ok "5"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3540kb

input:

9
1 3 2 14 15 13 8 6 7
12 11 4 17 9 5 18 10 16

output:

3

result:

ok "3"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

4
2 8 1 7
5 6 3 4

output:

2

result:

ok "2"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

10
9 17 7 11 14 13 2 3 16 1
20 10 6 15 5 8 4 12 18 19

output:

4

result:

ok "4"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

10
20 14 10 4 13 6 8 12 18 16
3 19 9 11 17 5 7 1 2 15

output:

6

result:

ok "6"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

9
4 14 11 12 9 10 8 7 15
2 16 1 13 18 6 17 3 5

output:

5

result:

ok "5"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3624kb

input:

10
3 17 13 18 16 20 10 5 1 19
7 6 4 14 2 11 9 8 15 12

output:

6

result:

ok "6"

Test #11:

score: -100
Wrong Answer
time: 0ms
memory: 10296kb

input:

821
37 1527 1243 1615 582 1085 1168 524 333 479 130 719 450 946 940 251 908 1458 729 267 1474 623 625 1002 1407 1297 1585 809 32 712 891 943 1331 82 648 655 1295 515 459 982 1486 691 896 1626 1105 903 1255 1593 1444 494 370 537 258 1196 862 1440 539 928 424 1080 1500 1330 317 906 288 727 735 580 811...

output:

410

result:

wrong answer 1st words differ - expected: '406', found: '410'