QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#689242#6433. Klee in Solitary Confinementlir_nutWA 29ms111432kbC++141.5kb2024-10-30 16:01:182024-10-30 16:01:19

Judging History

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

  • [2024-10-30 16:01:19]
  • 评测
  • 测评结果:WA
  • 用时:29ms
  • 内存:111432kb
  • [2024-10-30 16:01:18]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <cmath>
#include <set>
#include <stack>

#define test
#ifndef test
    freopen("in.in", stdin);
#endif

#define rint register int
#define ll long long
#define P pair<char, int> 
const int N = 2e6 + 50;

using namespace std;
int arr[N], s[N * 2];
vector<int> dic[N * 2];
void solution(){
    int n, k; scanf("%d%d", &n, &k);
    for(int i = 1; i <= n; i++){
        scanf("%d", &arr[i]);
        dic[arr[i] + N].push_back(-1);
        dic[arr[i] + k + N].push_back(1);
        s[arr[i] + N]++;
    }
    int ans = 0;
    for(int i = 0; i < 2 * N; i++){
        int maxnum = 0, minnum = 0, mxlabel = -1, mnlabel = -1, sub = 0;
        for(int j = 0; j < dic[i].size(); j++){
            if(j) dic[i][j] += dic[i][j - 1];
            if(dic[i][j] >= maxnum){
                sub += dic[i][j] - maxnum;
                maxnum = dic[i][j];
                mxlabel = j;
                if(mxlabel > mnlabel) sub = maxnum - minnum;
            }
            if(dic[i][j] < minnum){
                minnum = dic[i][j];
                mnlabel = j;
            }
        }
        ans = max(ans, s[i] + sub);
    }
    if(k == 0){
        ans = 0;
        for(int i = 0; i < 2 * N; i++) ans = max(ans, s[i]);
    }
    printf("%d", ans);
}

int main(){
    test
    int t = 1;
    //scanf("%d", &t);
    while (t--){
        solution();
        if(t) printf("\n");
    }
}

详细

Test #1:

score: 100
Accepted
time: 16ms
memory: 103096kb

input:

5 2
2 2 4 4 4

output:

5

result:

ok 1 number(s): "5"

Test #2:

score: 0
Accepted
time: 11ms
memory: 103120kb

input:

7 1
3 2 3 2 2 2 3

output:

6

result:

ok 1 number(s): "6"

Test #3:

score: 0
Accepted
time: 15ms
memory: 102924kb

input:

7 1
2 3 2 3 2 3 3

output:

5

result:

ok 1 number(s): "5"

Test #4:

score: 0
Accepted
time: 19ms
memory: 102456kb

input:

9 -100
-1 -2 1 2 -1 -2 1 -2 1

output:

3

result:

ok 1 number(s): "3"

Test #5:

score: 0
Accepted
time: 16ms
memory: 110740kb

input:

200 121649
0 527189 -1000000 -306471 -998939 527189 -1000000 -1000000 0 527189 0 527189 0 527189 -306471 -998939 -306471 -306471 -306471 0 0 527189 527189 1000000 527189 -1000000 1000000 648838 -1000000 -998939 -998939 -998939 0 1000000 -1000000 -998939 527189 1000000 648838 -1000000 1000000 648838 ...

output:

37

result:

ok 1 number(s): "37"

Test #6:

score: 0
Accepted
time: 24ms
memory: 110548kb

input:

200 -454379
-385892 454379 -1000000 373644 -665078 -1000000 -1000000 454379 0 1000000 373644 -1000000 1000000 -385892 -1000000 373644 0 -665078 0 -665078 -1000000 -665078 -385892 -665078 -385892 454379 -665078 -385892 -1000000 454379 1000000 -385892 373644 454379 -1000000 -385892 -1000000 -385892 -1...

output:

40

result:

ok 1 number(s): "40"

Test #7:

score: 0
Accepted
time: 19ms
memory: 110976kb

input:

200 0
451272 -1000000 677452 677452 0 18908 451272 677452 -233144 677452 451272 18908 -1000000 18908 -1000000 0 451272 0 -233144 677452 1000000 451272 1000000 18908 -1000000 0 -233144 451272 1000000 18908 677452 0 677452 0 677452 1000000 -233144 18908 451272 -1000000 -233144 18908 1000000 0 0 -23314...

output:

35

result:

ok 1 number(s): "35"

Test #8:

score: 0
Accepted
time: 16ms
memory: 110016kb

input:

200 -705945
-586687 198791 0 198791 0 705945 198791 -1000000 705945 705945 1000000 705945 0 -1000000 699023 0 705945 -586687 -1000000 198791 -1000000 1000000 198791 -1000000 198791 705945 -1000000 1000000 1000000 198791 198791 -1000000 699023 0 0 699023 -586687 705945 -586687 705945 699023 0 705945 ...

output:

34

result:

ok 1 number(s): "34"

Test #9:

score: 0
Accepted
time: 16ms
memory: 111088kb

input:

200 0
344286 0 -230711 532652 -589794 344286 532652 -1000000 -589794 344286 0 532652 -1000000 344286 344286 1000000 0 -1000000 532652 532652 532652 -230711 -1000000 344286 532652 532652 0 532652 1000000 0 0 1000000 -589794 -1000000 1000000 -1000000 -1000000 344286 0 344286 344286 1000000 -1000000 -1...

output:

34

result:

ok 1 number(s): "34"

Test #10:

score: 0
Accepted
time: 16ms
memory: 109752kb

input:

200 -230027
-1000000 -662604 0 1000000 59253 1000000 1000000 -662604 -662604 0 -70266 1000000 -300293 -300293 59253 1000000 -1000000 1000000 0 1000000 -662604 59253 -1000000 -70266 -1000000 -662604 -662604 59253 59253 -1000000 -70266 -70266 1000000 -300293 59253 59253 1000000 -70266 -1000000 -70266 ...

output:

33

result:

ok 1 number(s): "33"

Test #11:

score: 0
Accepted
time: 16ms
memory: 108052kb

input:

200 197410
1000000 -665711 0 -271800 -701554 -271800 -1000000 -665711 -665711 -1000000 -271800 1000000 -701554 1000000 -701554 -1000000 1000000 1000000 -1000000 -701554 1000000 -271800 -1000000 -197410 -665711 -701554 1000000 -1000000 -665711 -701554 -701554 -271800 -1000000 -1000000 -271800 -701554...

output:

37

result:

ok 1 number(s): "37"

Test #12:

score: 0
Accepted
time: 16ms
memory: 109888kb

input:

200 -96015
791544 -1000000 791544 -1000000 -668818 695529 1000000 -552146 -1000000 -668818 1000000 1000000 1000000 695529 695529 0 791544 -552146 0 1000000 791544 -668818 0 -1000000 0 -1000000 791544 -1000000 791544 1000000 791544 0 -1000000 0 -668818 695529 791544 1000000 695529 695529 -668818 -100...

output:

38

result:

ok 1 number(s): "38"

Test #13:

score: 0
Accepted
time: 22ms
memory: 108696kb

input:

200 -1000000
1000000 127969 0 0 0 -970611 0 0 293224 293224 293224 293224 -1000000 -970611 1000000 -1000000 820037 820037 820037 127969 127969 0 0 -970611 1000000 -970611 820037 -1000000 -970611 -1000000 820037 -970611 -1000000 127969 -970611 293224 1000000 293224 1000000 293224 293224 -1000000 8200...

output:

39

result:

ok 1 number(s): "39"

Test #14:

score: 0
Accepted
time: 21ms
memory: 108300kb

input:

200 0
0 527518 841746 0 331297 -1000000 595261 841746 527518 1000000 1000000 527518 1000000 527518 0 1000000 0 841746 527518 -1000000 595261 0 595261 -1000000 841746 841746 841746 0 -1000000 595261 331297 841746 0 841746 595261 0 595261 0 0 0 527518 331297 527518 0 841746 331297 0 1000000 -1000000 5...

output:

44

result:

ok 1 number(s): "44"

Test #15:

score: 0
Accepted
time: 15ms
memory: 110412kb

input:

200 -258363
704217 520353 810464 704217 -264059 270856 1000000 838639 810464 -264059 0 704217 945100 945100 813177 328488 1000000 270856 -1000000 1000000 520353 233383 328488 -522422 -187632 -187632 373822 810464 653545 838639 -264059 945100 -187632 -22847 810464 373822 373822 0 -187632 -22847 27085...

output:

17

result:

ok 1 number(s): "17"

Test #16:

score: 0
Accepted
time: 18ms
memory: 109328kb

input:

200 181089
-300523 -104331 360450 -108859 1000000 388283 -108859 -118869 -104331 -277725 360450 -104331 727661 1000000 -108859 727661 383704 727661 -628369 727661 -108859 -118869 388283 -83881 -655062 -655062 -199320 1000000 -1000000 -964033 -83881 -964033 -448024 1000000 -104331 569372 800854 38828...

output:

13

result:

ok 1 number(s): "13"

Test #17:

score: 0
Accepted
time: 20ms
memory: 110424kb

input:

200 117900
-838409 411806 34821 -766900 67987 34821 46504 46504 -49913 411806 161685 313760 -49913 596234 156661 67987 -646448 161685 -838409 46504 -236598 -766900 -538744 46504 -49913 599791 -1000000 -538744 34821 -646441 -236598 67987 0 -766900 161685 161685 -305084 34821 0 -49913 46504 -49913 156...

output:

14

result:

ok 1 number(s): "14"

Test #18:

score: 0
Accepted
time: 29ms
memory: 109956kb

input:

200 88724
-233297 630561 -275237 -275237 505621 416897 0 505621 0 -1000000 416897 -888093 -275237 630561 788662 788662 505621 -1000000 416897 -314063 584906 0 -1000000 -888093 1000000 276966 416897 311201 257302 493457 -852985 -233297 493457 563328 788662 -233297 1000000 584906 -1000000 416897 58490...

output:

14

result:

ok 1 number(s): "14"

Test #19:

score: 0
Accepted
time: 16ms
memory: 109656kb

input:

200 739055
-276846 -1000000 -970267 274436 -278344 -276846 690590 -780355 -619119 338671 681144 -970267 537803 338671 -780355 0 885372 -619119 -780355 -711246 235223 274436 445389 460711 460711 -276846 -1000000 690590 400277 681144 351497 -278344 885372 0 -1000000 -711246 -438285 537803 1000000 6905...

output:

15

result:

ok 1 number(s): "15"

Test #20:

score: 0
Accepted
time: 18ms
memory: 111432kb

input:

200 -942994
884626 1000000 -491267 884626 -26900 -362264 916094 -705196 -503120 -730425 -705196 -362264 -503120 763328 -26900 12314 -362264 -26900 -281451 1000000 -26900 -503120 916094 -501391 -501391 -705196 -491267 763328 -841371 636579 -730425 636579 -501391 -730425 -26900 -503120 -841371 -705196...

output:

16

result:

ok 1 number(s): "16"

Test #21:

score: 0
Accepted
time: 16ms
memory: 110692kb

input:

200 863782
-909322 180110 0 -354261 -98424 -539584 509521 -43919 -654935 -43919 -98424 -909322 -795454 -1000000 -5749 474004 932634 -783914 667659 474004 -43919 289728 -1000000 -795454 -43919 -654935 -354261 -179344 -539584 -886774 -43919 289728 1000000 1000000 509521 -179344 932634 180110 -5749 490...

output:

12

result:

ok 1 number(s): "12"

Test #22:

score: -100
Wrong Answer
time: 18ms
memory: 110616kb

input:

200 -86945
4973 274752 -348485 0 -661269 192390 -604418 -604418 0 366658 -618002 366658 200590 113645 1000000 4973 -491231 200590 -933401 -491231 -1000000 0 113645 -357368 192390 -348485 -348485 192390 642587 -462653 -110388 366658 -618002 642587 -491231 -618002 -462653 113645 366658 642587 779540 6...

output:

12

result:

wrong answer 1st numbers differ - expected: '15', found: '12'