QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#398146#5353. 最长上升子序列iee100 ✓145ms11800kbC++141.2kb2024-04-24 23:22:432024-04-24 23:22:44

Judging History

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

  • [2024-04-24 23:22:44]
  • 评测
  • 测评结果:100
  • 用时:145ms
  • 内存:11800kb
  • [2024-04-24 23:22:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
constexpr int N = 5e4 + 5, Q = 2e5 + 5;
int tr[N];
void upd(int x) { while (x < N) tr[x]++, x += x & -x; }
int ask(int x) { int r = 0; while (x) r += tr[x], x -= x & -x; return r; }
int n, q, a[N], B;
int answer[Q];
vector<array<int, 2>> que[N];
struct young {
	bool typ;
	vector<int> young[N];
	int num;
	void insert(int x) {
		for (int i = 1; i <= B; i++) {
			int id;
			if (!typ) id = lower_bound(young[i].begin(), young[i].end(), x) - young[i].begin();
			else id = upper_bound(young[i].begin(), young[i].end(), x) - young[i].begin();
			if (id == young[i].size()) {
				young[i].push_back(x);
				if (!typ) upd(young[i].size());
				else if (young[i].size() > B) upd(i);
				break;
			}
			swap(x, young[i][id]);
		}
	}
} t1, t2;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> n >> q, B = sqrt(n);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= q; i++) {
		int m, k;
		cin >> m >> k;
		que[m].push_back({k, i});
	}
	t2.typ = 1;
	for (int i = 1; i <= n; i++) {
		t1.insert(a[i]);
		t2.insert(N - a[i]);
		for (auto [m, id] : que[i]) {
			answer[id] = ask(m);
		}
	}
	for (int i = 1; i <= q; i++) {
		cout << answer[i] << "\n";
	}
	return 0;
}

详细

Test #1:

score: 5
Accepted
time: 42ms
memory: 9296kb

input:

50000 50000
50000 49999 49998 49997 49991 49992 49993 49994 49995 49996 49990 49989 49988 49987 49986 49985 49984 49983 49982 49981 49980 49979 49978 49977 49976 49975 49974 49973 49972 49971 49970 49969 49968 49967 49966 49965 49964 49963 49962 49961 49960 49959 49958 49957 49956 49955 49954 49953 ...

output:

1
2
3
4
5
5
5
5
5
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
10...

result:

ok 50000 numbers

Test #2:

score: 5
Accepted
time: 2ms
memory: 7296kb

input:

300 599
292 150 62 60 83 168 151 128 56 88 99 220 136 33 37 131 4 294 143 201 169 218 164 45 282 160 233 134 22 166 177 82 217 178 179 256 291 11 93 293 78 54 122 10 221 285 254 290 213 228 57 300 116 171 173 5 296 170 75 84 113 238 289 125 208 46 74 115 261 199 20 100 139 159 106 198 61 229 297 183...

output:

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

result:

ok 599 numbers

Test #3:

score: 5
Accepted
time: 3ms
memory: 7368kb

input:

3000 5999
3000 2999 2998 2997 2996 2995 2994 2993 2992 2991 2990 2989 2988 2987 2986 2985 2984 2983 2982 2981 2980 2979 2978 2977 2976 2975 2974 2973 2972 2971 2970 2969 2968 2967 2966 2965 2964 2963 2962 2961 2960 2959 2958 2957 2956 2955 2954 2953 2952 2951 2950 2949 2948 2947 2946 2945 2944 2943 ...

output:

1
2
2
3
3
4
4
5
5
6
6
7
7
8
8
9
9
10
10
11
11
12
12
13
13
14
14
15
15
16
16
17
17
18
18
19
19
20
20
21
21
22
22
23
23
24
24
25
25
26
26
27
27
28
28
29
29
30
30
31
31
32
32
33
33
34
34
35
35
36
36
37
37
38
38
39
39
40
40
41
41
42
42
43
43
44
44
45
45
46
46
47
47
48
48
49
49
50
50
51
51
52
52
53
53
54...

result:

ok 5999 numbers

Test #4:

score: 5
Accepted
time: 61ms
memory: 10660kb

input:

50000 200000
1 2 4 5 3 5 5 4 5 2 1 1 1 2 2 2 4 5 1 5 3 5 4 2 1 4 4 4 5 2 1 5 4 3 4 5 3 5 5 1 3 1 1 2 5 5 3 3 2 5 2 3 2 2 4 2 2 2 4 4 2 2 4 1 3 3 4 1 3 3 4 3 4 3 5 5 4 3 3 1 2 1 2 5 2 2 4 3 3 5 3 2 4 3 5 1 4 5 5 2 3 2 3 4 4 5 5 5 5 4 5 3 2 4 4 4 3 5 3 1 1 3 5 5 4 5 2 5 5 5 2 2 2 3 1 5 4 1 4 3 5 1 4 4...

output:

50000
49999
49998
49997
49996
49995
49994
49993
49992
49991
49990
49989
49988
49987
49986
49985
49984
49983
49982
49981
49980
49979
49978
49977
49976
49975
49974
49973
49972
49971
49970
49969
49968
49967
49966
49965
49964
49963
49962
49961
49960
49959
49958
49957
49956
49955
49954
49953
49952
49951
...

result:

ok 200000 numbers

Test #5:

score: 5
Accepted
time: 72ms
memory: 10732kb

input:

50000 200000
8 3 6 4 6 8 5 8 8 4 2 5 4 5 7 8 1 8 7 2 4 4 5 6 1 2 6 2 7 2 8 4 4 7 5 1 5 3 3 3 1 5 5 2 3 2 6 3 4 3 4 5 1 3 1 5 8 5 3 2 3 5 6 1 8 8 2 3 4 8 5 2 7 5 5 8 7 2 1 8 1 4 1 5 3 8 7 7 4 6 8 5 2 3 6 2 1 7 5 6 1 3 6 1 8 1 7 7 4 5 6 8 5 6 3 2 7 2 7 6 8 1 1 4 3 5 5 4 1 1 5 7 8 7 7 1 5 1 1 8 5 4 8 8...

output:

44006
44006
44005
44004
44003
44002
44002
44001
44000
43999
43998
43998
43998
43997
43996
43995
43994
43993
43993
43992
43991
43990
43989
43989
43988
43987
43986
43985
43984
43983
43982
43981
43980
43979
43978
43977
43976
43975
43974
43973
43972
43971
43970
43969
43968
43967
43966
43965
43964
43963
...

result:

ok 200000 numbers

Test #6:

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

input:

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

output:

20
35
48
59
67
74
80
84
88
91
94
96
98
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
1...

result:

ok 100 numbers

Test #7:

score: 5
Accepted
time: 1ms
memory: 7200kb

input:

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

output:

50
60
70
73
76
79
82
85
88
91
94
97
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
...

result:

ok 100 numbers

Test #8:

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

input:

800 10
786 762 748 726 712 789 764 758 711 737 714 794 795 703 713 769 696 765 796 797 771 746 729 799 800 692 773 727 710 683 775 718 793 767 798 754 750 747 680 744 774 791 709 694 756 753 792 788 790 751 749 740 691 684 739 738 785 787 717 672 782 784 781 770 768 668 674 736 783 673 742 732 766 7...

output:

301
601
700
741
761
781
798
800
800
800

result:

ok 10 numbers

Test #9:

score: 5
Accepted
time: 2ms
memory: 7644kb

input:

1500 10
1465 1469 1450 1466 1437 1479 1470 1482 1442 1485 1492 1494 1495 1431 1480 1436 1496 1499 1481 1484 1456 1443 1402 1376 1487 1458 1446 1369 1403 1364 1419 1490 1500 1424 1339 1460 1332 1462 1464 1476 1384 1372 1368 1447 1451 1493 1353 1410 1491 1440 1349 1441 1497 1417 1423 1429 1392 1397 13...

output:

701
1001
1101
1201
1301
1400
1441
1461
1481
1498

result:

ok 10 numbers

Test #10:

score: 5
Accepted
time: 3ms
memory: 8032kb

input:

10000 30
9874 9914 9870 9903 9868 9839 9896 9915 9881 9912 9905 9883 9838 9850 9864 9824 9925 9826 9918 9907 9832 9891 9807 9886 9783 9803 9727 9736 9830 9701 9852 9834 9797 9940 9766 9952 9919 9911 9948 9887 9929 9898 9921 9829 9932 9950 9951 9729 9760 9957 9808 9744 9860 9931 9965 9731 9920 9718 9...

output:

4963
7434
8699
9318
9621
9805
9862
9908
9918
9927
9935
9943
9951
9959
9967
9975
9983
9991
9999
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000
10000

result:

ok 30 numbers

Test #11:

score: 5
Accepted
time: 9ms
memory: 7844kb

input:

15000 40
14753 14777 14779 14942 15000 14999 14950 14916 14997 14954 14995 14967 14919 14864 14934 14973 14944 14891 14952 14786 14994 14982 14900 14793 14990 14905 14853 14927 14694 14883 14988 14807 14884 14826 14894 14697 14984 14831 14986 14915 14729 14987 14989 14848 14857 14846 14834 14762 149...

output:

7482
11210
13067
14028
14474
14714
14821
14869
14914
14942
14959
14961
14963
14965
14967
14969
14971
14973
14975
14977
14979
14981
14983
14985
14987
14989
14991
14993
14995
14997
14999
15000
15000
15000
15000
15000
15000
15000
15000
15000

result:

ok 40 numbers

Test #12:

score: 5
Accepted
time: 11ms
memory: 7732kb

input:

20000 50
19551 19559 19737 19666 19665 19608 19641 19610 19613 19854 19508 19599 19887 19698 19597 19684 19517 19661 19911 19656 19381 19935 19503 19692 19650 19399 19391 19719 19604 19363 19590 19350 19335 19969 19534 19739 19831 19747 19355 19330 19349 19324 19772 19861 19404 19577 19386 19751 194...

output:

6630
11045
13993
15989
17282
18177
18768
19132
19417
19449
19468
19487
19506
19525
19544
19563
19582
19601
19620
19639
19658
19677
19696
19715
19734
19753
19772
19791
19810
19829
19848
19867
19886
19905
19924
19943
19962
19981
20000
20000
20000
20000
20000
20000
20000
20000
20000
20000
20000
20000

result:

ok 50 numbers

Test #13:

score: 5
Accepted
time: 34ms
memory: 10960kb

input:

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

output:

17480
11289
12707
12895
17719
19255
17020
19004
19721
12130
16239
11152
13549
13635
16147
11535
16881
17248
16869
11655
14772
10296
18816
16515
13699
13775
16441
18618
16131
18725
18203
13641
15177
19510
16600
14597
19399
13236
14749
17432
18546
18002
12775
18135
13463
11906
18877
10169
15003
11679
...

result:

ok 200000 numbers

Test #14:

score: 5
Accepted
time: 7ms
memory: 7596kb

input:

8000 8000
137 141 7915 7904 7455 7946 7458 7862 7939 7771 7485 7443 7375 7936 7763 7921 7955 7934 7880 7589 142 148 7908 7959 7454 86 150 7957 7947 7620 7751 7740 7367 7436 7621 7321 7972 153 7370 7869 7836 7940 7736 7150 7983 157 7456 7914 165 7716 7451 7999 7953 7922 7997 7978 173 7525 7987 7336 7...

output:

1662
2755
3459
3964
4289
4520
4643
4712
4739
4748
4757
4766
4775
4784
4793
4802
4811
4820
4829
4838
4847
4856
4865
4874
4883
4892
4901
4910
4919
4928
4937
4946
4955
4964
4973
4982
4991
5000
5002
5004
5006
5008
5010
5012
5014
5016
5018
5020
5022
5024
5026
5028
5030
5032
5034
5036
5038
5040
5042
5044
...

result:

ok 8000 numbers

Test #15:

score: 5
Accepted
time: 62ms
memory: 11272kb

input:

25000 200000
22139 4715 21878 22180 21719 21573 21465 4716 22075 21774 22218 21370 4718 22283 22312 21087 4722 21061 21654 22110 20964 4724 21478 21817 21752 21413 21225 21565 22374 20698 21527 4725 21450 22126 22137 20586 22233 21861 21064 21777 21697 4727 21419 21032 21661 21253 21864 4728 20581 2...

output:

1
2
3
4
3
4
5
6
8
9
11
10
7
14
15
13
8
16
18
20
9
10
15
18
19
16
17
22
29
18
24
11
26
32
35
27
37
30
31
34
32
12
34
21
41
30
47
22
32
50
51
13
40
44
48
41
57
51
24
54
61
47
48
55
49
57
43
35
62
56
71
61
14
26
54
47
48
71
57
71
72
82
83
58
76
59
15
79
28
90
40
82
93
84
85
68
69
75
29
82
101
88
30
104...

result:

ok 200000 numbers

Test #16:

score: 5
Accepted
time: 145ms
memory: 11800kb

input:

40000 200000
33737 32950 33874 33923 33970 34029 34063 34113 32972 32938 32526 34217 31966 33029 34321 31424 33249 31398 30468 32949 34383 32630 33295 32003 31523 33423 33007 31507 33465 34500 30590 34569 32699 33709 30435 30475 32094 29922 29602 31550 31534 33713 29937 33757 30807 28850 33775 30627...

output:

1
2
3
4
5
6
7
8
4
3
4
12
5
9
15
6
12
7
8
11
21
12
18
13
14
22
17
15
26
30
16
32
20
30
9
18
23
10
11
26
27
39
21
42
29
12
46
31
34
35
38
39
53
32
23
55
13
45
59
35
47
40
45
50
14
15
27
68
39
28
16
72
59
30
61
17
18
66
50
80
33
19
67
84
35
59
54
20
62
49
37
80
58
94
79
59
51
38
95
83
98
74
90
62
53
90...

result:

ok 200000 numbers

Test #17:

score: 5
Accepted
time: 90ms
memory: 11588kb

input:

45000 200000
1619 1621 1629 1295 761 430 1630 1297 372 764 438 1304 771 1311 374 44982 360 1633 772 442 1314 317 443 187 1642 369 776 318 188 388 402 1332 44981 371 326 1651 44973 1660 784 446 1662 376 405 189 1347 1666 382 330 1671 44961 44945 332 786 58 44942 192 1 1357 790 44941 1364 195 791 449 ...

output:

1
2
3
2
3
4
7
6
5
8
9
11
12
14
10
16
6
18
17
15
21
7
20
8
25
14
26
15
16
21
26
32
33
22
23
36
37
35
33
29
41
30
36
24
43
46
32
9
49
50
47
40
44
10
51
19
11
48
49
57
58
44
51
52
63
66
64
68
21
30
58
12
32
13
75
72
42
51
60
65
43
67
80
53
83
63
87
73
82
74
14
92
90
15
93
88
77
72
93
99
101
96
82
73
10...

result:

ok 200000 numbers

Test #18:

score: 5
Accepted
time: 95ms
memory: 11672kb

input:

50000 200000
49993 49987 49979 49978 49975 21185 20712 20347 21191 20747 21203 49969 49967 20764 20348 20379 20327 20333 21218 20160 21222 19942 21229 19925 21230 20341 20786 21240 49952 20796 20800 21256 20161 20807 19808 21257 20176 20407 20817 20408 49946 20839 20416 20433 49939 19729 21267 20843...

output:

1
2
3
4
5
6
7
8
9
10
11
12
12
11
9
15
10
14
19
11
21
12
23
13
25
21
24
28
29
26
28
30
18
26
14
36
24
29
37
32
41
40
35
38
44
15
42
21
22
28
23
52
52
30
55
24
57
37
16
17
54
27
41
35
46
50
43
55
36
18
46
62
51
69
19
57
75
78
79
39
75
63
49
55
70
56
57
84
58
20
65
92
89
90
60
21
94
98
96
68
96
82
100
...

result:

ok 200000 numbers

Test #19:

score: 5
Accepted
time: 85ms
memory: 11628kb

input:

50000 200000
49858 49948 49965 49860 191 49967 1 49999 197 49977 49982 49995 2 49866 49994 49991 198 49868 3 199 4 49983 49986 49883 201 49890 202 49892 203 49898 49988 49981 49976 5 206 49973 49970 49993 49962 6 49997 49905 50000 49957 7 49913 49917 209 211 213 49927 8 9 49947 10 49929 49946 49931 ...

output:

1
2
3
2
3
6
4
8
6
8
11
12
7
10
12
8
5
15
6
14
7
20
23
21
19
24
25
27
28
30
31
32
31
8
24
36
9
38
10
11
41
31
43
42
12
36
46
13
46
49
51
14
42
54
46
55
57
50
59
60
15
16
56
61
63
66
65
17
68
70
63
18
72
74
67
70
19
78
79
74
20
21
83
84
79
82
87
22
89
86
88
23
24
94
25
92
26
27
96
97
101
102
28
104
10...

result:

ok 200000 numbers

Test #20:

score: 5
Accepted
time: 79ms
memory: 11720kb

input:

50000 200000
49937 1 49949 49964 49857 2 48495 3 49998 4 49859 49865 49996 5 48496 48497 6 49990 49981 7 48499 48503 49976 49975 48506 49972 48511 48514 48516 49966 49871 49969 49980 49881 48518 48521 49955 48522 49953 48523 8 49952 49889 49982 49951 9 49891 48524 10 49984 48528 49897 11 48530 49992...

output:

1
2
3
4
4
3
7
4
9
10
11
12
13
7
10
13
8
18
12
5
17
22
23
6
7
26
8
28
29
30
9
32
33
23
10
25
27
28
39
11
12
42
28
44
33
13
33
14
15
50
38
40
39
42
55
44
45
58
43
60
61
16
17
49
51
53
67
55
18
58
71
53
73
19
57
76
20
64
79
56
62
21
83
84
22
62
68
88
23
90
72
74
24
25
95
26
78
27
28
82
83
102
103
29
10...

result:

ok 200000 numbers

Extra Test:

score: 0
Extra Test Passed