QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#99680#4803. Candiesckiseki#AC ✓16ms3996kbC++201.3kb2023-04-23 14:46:112023-04-23 14:46:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-23 14:46:15]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:3996kb
  • [2023-04-23 14:46:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define orange(a...) orange_(#a, a)
#define debug(a...) debug_(#a, a)
template <typename i>
void orange_(const char * s, i l, i r) {
    cerr << "\e[1;32m[ " << s << " ] = [ ";
    for (int f = 0; l != r; l++)
        cerr << (f++ ? " " : "") << *l;
    cerr << " ]\e[0m\n";
}
template <typename ...T>
void debug_(const char * s, T ...a) {
    cerr << "\e[1;32m(" << s << ") = (";
    int cnt = sizeof...(T);
    (..., (cerr << a << (--cnt ? ", " : ")\e[0m\n")));
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for (int &ai : a) {
        cin >> ai;
        ai = min(ai, x - ai);
    }
    deque<int> dq;
    for (int ai : a) {
        if (dq.empty())
            dq.push_back(ai);
        else if (dq.back() == ai)
            dq.pop_back();
        else
            dq.push_back(ai);
    }
    while (dq.size() >= 2) {
        if (dq.front() == dq.back()) {
            dq.pop_front();
            dq.pop_back();
        } else break;
    }
    cout << (n - dq.size()) / 2 << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3436kb

input:

6 5
1 1 4 5 1 4

output:

2

result:

ok 1 number(s): "2"

Test #2:

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

input:

10 5
1 2 5 2 1 2 3 4 8 4

output:

3

result:

ok 1 number(s): "3"

Test #3:

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

input:

1 963837006
731841442

output:

0

result:

ok 1 number(s): "0"

Test #4:

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

input:

2 948507270
461613425 139535653

output:

0

result:

ok 1 number(s): "0"

Test #5:

score: 0
Accepted
time: 14ms
memory: 3920kb

input:

100000 253614967
278270961 980235896 498158919 928430171 216003120 852570559 948400591 239257297 897053668 294741177 38297442 382677591 406314558 609468974 854148233 314532768 738191552 158215003 5865826 920471827 380037059 356271729 749175328 28319050 208101106 953758996 896570759 521930645 2413736...

output:

0

result:

ok 1 number(s): "0"

Test #6:

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

input:

100000 2
1 2 2 2 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2 2 1 2 1 1 1 2 2 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 2 1 1 2 1 1 2 2 2 2 1 2 2 2 1 1 2 1 2 1 2 2 2 1 1 1 2 1 1 1 1 1 1 1 2 1 2 1 1 2 1 2 1 2 1 2 1 2 2 1 1 2 2 2 1 1 2 1 1 2 2 2 2 2 2 2 1 2 1 1 2 2 1 1 2 1 1 1 1...

output:

49999

result:

ok 1 number(s): "49999"

Test #7:

score: 0
Accepted
time: 3ms
memory: 3416kb

input:

99824 2
1 1 2 1 1 1 2 1 2 2 2 2 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 2 1 2 2 1 1 2 2 1 2 1 1 1 2 2 1 2 1 1 2 1 2 1 2 2 2 1 1 2 1 2 2 2 2 2 1 2 1 1 2 1 1 2 1 2 2 1 2 1 2 2 1 2 2 1 2 2 2 1 1 2 1 2 1 1 1 2 1 1 2 2 1 1 2 2 1 1 1 2 2 1 2 1 1 2 2 2 1 1 2 1 1 2 1 1 1 2 1 1 1 2 1 1 2 1 2 1 1 1 ...

output:

49904

result:

ok 1 number(s): "49904"

Test #8:

score: 0
Accepted
time: 9ms
memory: 3880kb

input:

100000 2094
5226 2958 8712 7230 6625 2487 4520 9360 2727 5423 5170 3199 3725 2419 9194 1946 9942 7780 9861 692 2218 5879 9116 3253 1191 710 8703 759 3019 3581 3648 105 6123 8494 6356 8000 3056 4478 2646 7457 2437 9669 4132 4585 8874 2930 9024 6773 132 4309 6496 8138 3514 531 4782 5854 1722 5046 8344...

output:

10

result:

ok 1 number(s): "10"

Test #9:

score: 0
Accepted
time: 7ms
memory: 3916kb

input:

100000 13036
23902 71466 9482 98728 78471 22915 2470 5999 53211 25994 3996 11349 30511 56448 17277 78308 18316 42069 38636 63127 26256 63985 57249 58305 64366 17839 28518 18980 95945 36316 6076 69530 96509 6940 6039 56048 41847 82118 41054 49670 95896 45891 74636 90736 75413 27251 87730 68344 66202 ...

output:

2

result:

ok 1 number(s): "2"

Test #10:

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

input:

100000 1000000000
200256279 980163173 150977009 767372228 582764043 266974730 643155483 835343794 21321428 879452350 591885316 154438918 900364435 545147788 658790005 179705816 697056697 995420303 943796510 917775810 218491919 453075898 2415016 995364028 660033907 366396048 415773047 341359040 99318...

output:

52

result:

ok 1 number(s): "52"

Test #11:

score: 0
Accepted
time: 13ms
memory: 3996kb

input:

100000 1000000000
930075041 382964463 32067726 285653188 451764399 121999168 242859626 923317013 493093976 435530600 599304758 19239760 605622974 58189530 743466763 461890312 450384720 113115571 150860432 739506450 146715736 606749237 443822591 586186363 455300271 934351943 190492840 188221364 79576...

output:

466

result:

ok 1 number(s): "466"

Test #12:

score: 0
Accepted
time: 14ms
memory: 3936kb

input:

100000 1000000000
28787963 903442008 498505673 786768844 2780988 260872048 803015736 179422223 438668270 50410272 949589728 713791959 42277723 675211206 285441462 805910070 799006739 729642043 274066126 771720227 985249963 147758876 18863375 329090560 875735992 616907347 677120292 996288994 39354661...

output:

5016

result:

ok 1 number(s): "5016"

Test #13:

score: 0
Accepted
time: 5ms
memory: 3736kb

input:

100000 1000000000
919904259 657106699 456489350 73335262 482319824 80954785 80954785 439309845 430263074 836709425 836709425 253860967 253860967 607421402 95008942 484440521 761289662 678820442 417290752 828224063 971351049 29588529 443998057 617366568 740517710 222054375 870322992 448320457 5482505...

output:

10107

result:

ok 1 number(s): "10107"

Test #14:

score: 0
Accepted
time: 7ms
memory: 3700kb

input:

100000 1000000000
774385080 964900197 365398016 744436356 503493016 496506984 440140095 139026794 311620979 87094613 912905387 752074900 938826429 697071589 27040552 218512285 781413020 218586980 898898505 425739571 55138594 489740170 484069475 457442504 143211885 541971054 541971054 102277341 56997...

output:

14852

result:

ok 1 number(s): "14852"

Test #15:

score: 0
Accepted
time: 10ms
memory: 3704kb

input:

100000 1000000000
762064238 237935762 83539103 956410339 496805469 293876386 476311967 857139149 740121784 844690650 247724925 846852127 846852127 390968943 872719626 872719626 781866487 94752143 726879321 822815540 263234519 163917251 904503819 904503819 218899653 721743564 278256436 393501898 6171...

output:

19881

result:

ok 1 number(s): "19881"

Test #16:

score: 0
Accepted
time: 5ms
memory: 3704kb

input:

100000 1000000000
773521685 53210169 87451051 63698384 63698384 87451051 106448763 9868594 965666221 965666221 359923109 304547627 304547627 562955901 237982702 762017298 720077827 157500371 104606639 450121676 383428765 123242383 962196953 977879399 451919378 514041727 904985040 203881325 176590362...

output:

24926

result:

ok 1 number(s): "24926"

Test #17:

score: 0
Accepted
time: 13ms
memory: 3700kb

input:

100000 1000000000
933814715 66185285 350381988 652183118 723703341 276296659 277472633 1026982 998973018 722527367 53171194 963898732 65060415 685876574 894604685 894604685 804152500 627238810 396815250 314298890 314298890 579573293 51934860 730845477 269154523 799932756 200067244 51934860 579573293...

output:

29943

result:

ok 1 number(s): "29943"

Test #18:

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

input:

100000 1000000000
57897508 942102492 536719025 463280975 975530922 389293162 118330387 118330387 959184761 918050065 918050065 292047793 619111506 619111506 707952207 798465709 686141037 686141037 775795227 106646738 329921037 811153537 188846463 842056436 675098719 692200871 692200871 13898261 4850...

output:

34943

result:

ok 1 number(s): "34943"

Test #19:

score: 0
Accepted
time: 12ms
memory: 3552kb

input:

100000 1000000000
188142286 648998022 752674766 59777379 298683825 384966485 49558677 412759965 765244406 234755594 412759965 83829760 916170240 49558677 886539189 113460811 787290997 965392742 769971404 647356058 647356058 769971404 942276537 301797849 698202151 57723463 965392742 787290997 1654148...

output:

39865

result:

ok 1 number(s): "39865"

Test #20:

score: 0
Accepted
time: 6ms
memory: 3504kb

input:

100000 1000000000
681653151 681653151 554684632 810320965 576612402 849513731 849513731 669266970 225801445 298094325 701905675 774198555 330733030 931202988 68797012 136082895 744706484 255293516 136082895 576612402 189679035 541425471 773924619 226075381 541425471 554684632 550114454 312343710 687...

output:

45061

result:

ok 1 number(s): "45061"

Test #21:

score: 0
Accepted
time: 13ms
memory: 3512kb

input:

100000 1000000000
807017217 334163866 864724184 169472311 546038384 139109841 519003847 873446718 518609291 993321735 725534356 577533579 983865191 932193586 310969165 187029164 389152043 141919565 556001622 727325693 760135785 734642252 63772048 846365607 143913353 184773759 472281163 886030391 763...

output:

50000

result:

ok 1 number(s): "50000"

Test #22:

score: 0
Accepted
time: 8ms
memory: 3784kb

input:

100000 10
89 7 3 7 7 79 9 9 4 6 11 28 45 3 3 2 2 8 2 3 7 93 5 5 14 99 5 5 5 5 24 20 88 2 8 6 8 2 6 98 4 6 45 43 93 70 90 75 5 5 49 50 4 22 9 19 7 2 8 3 83 1 9 53 19 48 90 91 61 51 51 44 87 46 68 7 42 8 51 4 4 2 8 1 30 27 78 58 5 5 37 61 4 6 57 2 8 5 90 8 8 4 4 8 4 4 6 4 7 7 8 20 1 1 5 3 7 5 1 9 38 1...

output:

25446

result:

ok 1 number(s): "25446"

Test #23:

score: 0
Accepted
time: 7ms
memory: 3472kb

input:

100000 10
9 3 5 2 7 5 8 5 8 8 2 5 5 8 7 6 6 7 2 1 5 9 5 5 7 4 5 3 2 7 5 3 3 7 5 2 9 8 3 5 6 3 5 8 2 7 5 9 8 7 2 3 7 5 7 2 5 8 4 2 8 4 4 7 2 8 2 5 8 6 3 5 5 9 5 1 3 5 7 9 9 5 1 3 6 1 4 9 9 9 2 2 6 1 3 4 9 1 4 8 4 5 1 6 6 7 4 3 9 6 5 5 6 8 2 3 4 2 1 2 8 9 6 4 9 8 1 4 8 5 5 8 8 3 1 7 3 1 9 4 6 1 8 6 2 ...

output:

50000

result:

ok 1 number(s): "50000"

Test #24:

score: 0
Accepted
time: 9ms
memory: 3632kb

input:

98425 1000
815 185 644 752 985 9379 8736 599 599 1766 7784 4572 5415 4347 1449 78 922 5693 8287 651 349 2062 2728 8897 5841 7351 2801 410 410 4931 5517 965 35 8482 767 853 147 233 513 513 89 89 3945 4465 7410 6621 2721 8756 2355 9766 284 716 1197 3408 5198 1110 9961 1829 1906 7378 2003 743 974 974 5...

output:

22606

result:

ok 1 number(s): "22606"

Test #25:

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

input:

10 10
59 20 19 8 2 68 95 72 61 42

output:

1

result:

ok 1 number(s): "1"

Test #26:

score: 0
Accepted
time: 9ms
memory: 3776kb

input:

100000 1000
317 317 304 508 508 6014 815 815 30 683 357 357 683 970 2929 5418 7694 381 619 632 632 9695 5899 6577 727 754 754 637 8896 8755 273 366 634 727 761 2798 7303 4363 3753 1396 8835 6487 609 391 6009 487 5717 1470 842 842 4211 7543 8106 583 276 276 8251 1157 6846 6034 3992 2577 1053 2339 312...

output:

21171

result:

ok 1 number(s): "21171"

Test #27:

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

input:

100000 100000
79922 20078 53995 46005 32359 61535 15343 15343 78961 730761 338563 197186 66714 630322 998034 12241 12241 868431 733944 213911 882481 959610 22712 38886 38886 43532 76942 23058 56468 22712 19843 476908 713934 175808 770875 994580 657509 792941 152756 138739 84015 44975 135115 179352 2...

output:

32249

result:

ok 1 number(s): "32249"

Test #28:

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

input:

100000 10000000
3350847 6649153 6727419 4244727 28285370 64225897 1520717 84820290 83748267 2604198 2604198 47318662 93285309 38893924 5620763 633944 9366056 4379237 72770346 76824422 55299128 3606747 3606747 86641543 6921816 70230158 3851442 2598278 8438230 3086243 6913757 1561770 2598278 6148558 4...

output:

37127

result:

ok 1 number(s): "37127"

Test #29:

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

input:

3 2
1 1 1

output:

1

result:

ok 1 number(s): "1"

Test #30:

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

input:

3 1
1 1 1

output:

1

result:

ok 1 number(s): "1"