QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#76220#5378. 匹配问题team13770 2ms3724kbC++141.0kb2023-02-08 15:22:562023-02-08 15:22:59

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-08 15:22:59]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:3724kb
  • [2023-02-08 15:22:56]
  • 提交

answer


#include <bits/stdc++.h>

using namespace std; const int maxn = 5e3 + 5;

int n, la, lb, a[maxn], b[maxn], p[maxn];

int main()
{
    scanf("%d%d%d", &n, &la, &lb);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    for (int i = 1; i <= n; i++) scanf("%d", b + i);
    for (int i = 1; i <= n; i++) p[i] = i;
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    int ans = 0;
    for (int i = n, j = n; i; i--)
    {
        while (j && b[j] > a[i] + lb) j--;
        if (b[j] >= a[i])
        {
            int fl = 1, las = p[i];
            for (int k = i - 1; p[k] >= j; k--)
            {
                if (b[las] > a[k] + la) { fl = 0; break; }
                las = p[k];
            }
            if (fl)
            {
                las = j;
                for (int k = i - 1; p[k] >= j; k--)
                {
                    swap(las, p[k]);
                }
                ans++;
                j--;
            }
        }
    }
    return 0 * printf("%d\n", ans);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 4
Accepted
time: 2ms
memory: 3496kb

input:

2 2 1
1 1
1 1

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 2ms
memory: 3724kb

input:

10 200000 100000
34181 300096 24293 22680 402306 193269 438170 254676 188147 73971
216849 477743 461911 135785 467234 278230 287107 223666 124173 135091

output:

7

result:

ok single line: '7'

Test #3:

score: 0
Accepted
time: 2ms
memory: 3608kb

input:

10 200000 50000
298370 136488 436143 52173 206095 140981 321188 407844 342157 193338
138374 383207 156748 442404 386749 492604 354156 229996 447123 418264

output:

5

result:

ok single line: '5'

Test #4:

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

input:

10 50000 30000
306273 53088 405351 218373 335275 277816 451436 105244 418031 83336
489843 323727 219514 102964 141689 337190 131790 312365 431836 413688

output:

5

result:

ok single line: '5'

Test #5:

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

input:

10 80000 60000
224299 63826 419731 459681 408367 139676 239118 115180 368327 179613
289195 106688 418781 143169 441337 255686 228353 373168 489321 173199

output:

10

result:

ok single line: '10'

Test #6:

score: -4
Wrong Answer
time: 2ms
memory: 3564kb

input:

10 150000 80000
218617 21495 443909 77126 349241 169574 387539 106419 251533 138042
427196 237082 192262 56014 357102 109789 495939 197573 273744 498979

output:

8

result:

wrong answer 1st lines differ - expected: '7', found: '8'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Runtime Error

Test #100:

score: 0
Runtime Error

input:

500000 500000 10
200184 74991 71203 334998 316800 34483 120570 301054 331108 232072 189788 397143 490296 56807 361700 88818 42376 460305 371750 450351 338384 429789 426045 445029 152316 408919 188124 144966 457495 475025 225370 260510 383159 495247 54319 246245 240728 372033 439599 119720 449020 451...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

0%