QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#691120#5147. Stack Sorttsai#AC ✓29ms4408kbC++14854b2024-10-31 09:59:052024-10-31 09:59:05

Judging History

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

  • [2024-10-31 09:59:05]
  • 评测
  • 测评结果:AC
  • 用时:29ms
  • 内存:4408kb
  • [2024-10-31 09:59:05]
  • 提交

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 = 5e5 + 50;

using namespace std;
int arr[N];
bool dic[N];
void solution(){
    int n; scanf("%d", &n);
    for(int i = 1; i <= n + 10; i++) dic[i] = false;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        int tmp; scanf("%d", &tmp);
        if(!dic[tmp + 1]) ans++;
        dic[tmp] = true;
    } 
    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: 0ms
memory: 3880kb

input:

3
3
1 2 3
3
3 2 1
5
1 4 2 5 3

output:

3
1
4

result:

ok 3 number(s): "3 1 4"

Test #2:

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

input:

100000
4
3 4 2 1
5
5 4 1 3 2
4
3 1 4 2
4
4 2 1 3
4
1 3 2 4
4
4 2 3 1
4
3 2 1 4
5
1 2 3 4 5
5
5 2 3 1 4
5
1 3 5 4 2
5
4 3 2 1 5
5
3 4 2 1 5
5
5 4 3 2 1
4
3 4 2 1
5
4 2 5 1 3
5
4 1 5 2 3
4
3 4 1 2
4
2 1 3 4
5
4 3 2 5 1
4
4 2 1 3
5
3 1 5 2 4
4
4 1 2 3
5
1 5 2 4 3
5
4 1 3 5 2
5
4 2 3 5 1
5
1 2 3 4 5
5
4...

output:

2
2
3
2
3
2
2
5
3
3
2
3
1
2
3
4
3
3
2
2
3
3
3
3
3
5
4
3
3
2
3
2
3
3
3
2
2
4
2
4
3
2
4
2
3
4
2
3
3
2
3
3
2
3
2
3
2
3
3
3
3
3
3
2
2
3
2
2
3
3
2
2
2
3
3
3
3
3
2
2
3
3
3
3
4
3
3
3
3
3
4
3
2
3
3
2
3
3
3
3
2
4
3
3
2
1
4
2
3
2
2
3
2
2
3
3
2
2
2
3
3
2
4
4
2
3
2
2
2
3
3
3
2
4
3
2
3
3
3
3
3
4
2
2
1
2
3
4
3
3
...

result:

ok 100000 numbers

Test #3:

score: 0
Accepted
time: 25ms
memory: 3764kb

input:

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

output:

5
6
5
4
5
5
6
6
5
6
4
5
6
6
6
5
7
7
5
6
5
5
7
5
8
3
6
5
5
6
4
5
6
4
5
4
4
5
4
4
6
5
5
6
5
4
7
4
5
7
5
5
7
4
7
4
6
5
6
4
6
6
5
4
5
6
5
5
6
5
3
5
5
5
5
6
7
6
5
5
7
3
5
5
7
5
6
4
5
4
6
5
4
6
5
7
5
5
6
5
6
6
3
6
6
4
5
6
5
5
5
4
6
3
5
4
6
5
5
7
5
5
6
6
4
4
6
5
7
5
6
3
6
3
5
5
5
4
5
5
5
6
6
4
6
6
5
4
5
6
...

result:

ok 50000 numbers

Test #4:

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

input:

5000
94
69 86 59 9 67 89 24 63 14 18 16 11 19 46 23 40 4 55 53 61 30 3 78 29 15 74 32 41 51 13 77 47 66 92 57 45 42 21 62 43 26 1 84 75 71 54 73 36 39 48 88 8 80 64 58 10 60 76 17 70 25 37 38 6 72 91 7 20 68 2 35 44 90 79 50 93 81 94 27 33 5 52 28 82 56 87 31 22 83 34 65 85 49 12
97
44 97 28 56 95 6...

output:

48
48
50
49
43
48
47
42
42
47
42
49
50
47
43
44
53
49
46
46
51
53
51
55
55
45
47
47
46
50
47
48
48
48
52
46
49
50
51
49
48
50
51
43
53
45
50
46
46
45
47
49
51
48
50
49
44
49
53
45
45
48
48
48
49
47
44
44
51
45
50
49
50
45
48
49
48
51
47
49
53
47
49
44
48
48
44
50
47
50
51
44
53
42
52
55
50
49
47
48
...

result:

ok 5000 numbers

Test #5:

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

input:

500
959
670 618 579 212 780 557 380 412 672 951 777 921 684 768 99 952 140 122 139 919 623 17 911 18 880 790 625 505 307 747 801 754 783 146 757 263 285 228 719 640 199 193 105 234 847 842 348 159 823 577 466 954 850 851 643 802 819 317 826 55 617 690 604 229 570 254 759 575 498 240 397 736 864 415 ...

output:

473
472
468
454
477
480
484
457
472
443
469
507
483
476
493
495
491
481
500
480
514
447
484
483
453
468
444
456
474
468
501
485
461
499
458
483
506
516
475
464
446
465
475
475
446
457
500
493
478
481
451
452
473
464
442
505
493
483
486
448
499
464
477
483
507
491
442
490
480
492
492
472
473
459
464
...

result:

ok 500 numbers

Test #6:

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

input:

50
9597
2421 5801 7761 5556 4158 3033 4751 9284 3326 1858 2849 8472 5917 6077 4438 1948 5294 3028 4716 8042 2671 5305 5076 6924 5569 8173 6362 2160 3095 7385 1374 3167 8128 551 2363 1371 5799 3273 1366 5050 7680 198 5577 1236 2843 1127 5381 3029 6977 4823 702 8077 528 526 7027 4278 7947 6058 5005 90...

output:

4807
4635
4549
4566
4833
4548
4946
4695
4657
4745
4934
4675
4887
4802
4931
4559
4968
4688
4606
4637
4577
4629
4821
4505
4561
4844
4611
4688
4817
4967
4713
4824
4654
4523
4808
4964
4619
4788
4927
4630
4912
4842
4751
4529
4644
4623
4633
4518
4604
4914

result:

ok 50 numbers

Test #7:

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

input:

5
92316
4486 51971 40435 31486 22840 51804 19355 35116 71427 50525 34461 46690 44101 15605 33166 25846 90319 50846 8819 36285 58519 23478 20717 14434 37378 37454 60063 17182 70164 59883 45000 84942 58799 11505 13371 52739 66680 30438 67677 41266 53940 34428 79533 55092 76616 54423 21642 25614 48002 ...

output:

46162
50067
48874
46319
48245

result:

ok 5 number(s): "46162 50067 48874 46319 48245"

Test #8:

score: 0
Accepted
time: 27ms
memory: 4408kb

input:

1
471631
424496 112701 456051 347801 218724 312785 85999 325031 220919 219326 327801 239646 431816 121964 216653 223784 147176 29672 466026 412872 269415 238525 365823 442104 346534 297299 298496 242174 296754 297691 105566 80641 204310 21696 170588 199258 59123 336907 57422 387873 209433 272911 261...

output:

235867

result:

ok 1 number(s): "235867"

Test #9:

score: 0
Accepted
time: 27ms
memory: 4376kb

input:

1
488063
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

488063

result:

ok 1 number(s): "488063"

Test #10:

score: 0
Accepted
time: 27ms
memory: 4276kb

input:

1
471416
471416 471415 471414 471413 471412 471411 471410 471409 471408 471407 471406 471405 471404 471403 471402 471401 471400 471399 471398 471397 471396 471395 471394 471393 471392 471391 471390 471389 471388 471387 471386 471385 471384 471383 471382 471381 471380 471379 471378 471377 471376 4713...

output:

1

result:

ok 1 number(s): "1"

Test #11:

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

input:

10
48868
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100...

output:

48868
46330
46349
49671
45183
48535
49233
49749
45094
46815

result:

ok 10 numbers

Test #12:

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

input:

10
45668
45668 45667 45666 45665 45664 45663 45662 45661 45660 45659 45658 45657 45656 45655 45654 45653 45652 45651 45650 45649 45648 45647 45646 45645 45644 45643 45642 45641 45640 45639 45638 45637 45636 45635 45634 45633 45632 45631 45630 45629 45628 45627 45626 45625 45624 45623 45622 45621 456...

output:

1
1
1
1
1
1
1
1
1
1

result:

ok 10 numbers