QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#345362#7662. Kaldorian Knightshht2005AC ✓59ms7900kbC++14574b2024-03-06 20:52:282024-03-06 20:52:28

Judging History

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

  • [2024-03-06 20:52:28]
  • 评测
  • 测评结果:AC
  • 用时:59ms
  • 内存:7900kb
  • [2024-03-06 20:52:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 1000010, mod = 1e9 + 7;
int f[5010], P[N], h[5010];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	P[0] = 1;
	for(int i = 1; i <= n; i++)
		P[i] = 1ll * i * P[i - 1] % mod;
	for(int i = 1; i <= k; i++) {
		scanf("%d", h + i);
		n -= h[i];
	}
	f[k + 1] = P[n];
	for(int i = k; i >= 1; i--) {
		int sum = 0;
		for(int j = i; j <= k; j++) {
			sum += h[j];
			f[i] = (f[i] + 1ll * P[sum] * f[j + 1]) % mod;
		}
		f[i] = (P[sum + n] - f[i] + mod) % mod;
	}
	printf("%d\n", f[1]);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3820kb

input:

3 0

output:

6

result:

ok single line: '6'

Test #2:

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

input:

4 1
3

output:

18

result:

ok single line: '18'

Test #3:

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

input:

4 2
2
1

output:

16

result:

ok single line: '16'

Test #4:

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

input:

10 1
10

output:

0

result:

ok single line: '0'

Test #5:

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

input:

10 10
1
1
1
1
1
1
1
1
1
1

output:

0

result:

ok single line: '0'

Test #6:

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

input:

1357 7
56
173
21
103
96
149
38

output:

1000000006

result:

ok single line: '1000000006'

Test #7:

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

input:

1357 5
190
198
257
256
261

output:

1000000005

result:

ok single line: '1000000005'

Test #8:

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

input:

1357 7
144
56
113
20
113
141
107

output:

0

result:

ok single line: '0'

Test #9:

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

input:

1357 7
107
29
131
99
180
96
63

output:

1

result:

ok single line: '1'

Test #10:

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

input:

1357 7
124
180
60
103
142
145
68

output:

2

result:

ok single line: '2'

Test #11:

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

input:

750 66
7
2
2
1
7
10
9
10
5
9
10
11
11
5
4
3
8
6
5
5
6
9
5
1
7
11
8
5
4
6
4
2
7
2
9
11
4
8
10
8
6
2
8
7
11
3
10
9
4
3
7
5
5
9
6
2
10
7
5
2
5
4
9
3
11
9

output:

685840434

result:

ok single line: '685840434'

Test #12:

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

input:

750 66
6
1
3
6
6
2
11
7
4
4
7
5
4
9
7
2
2
6
7
10
6
3
5
4
6
5
6
5
3
10
7
9
6
5
11
1
1
9
4
6
7
3
3
4
7
11
4
5
1
8
7
10
9
10
2
6
6
5
8
8
4
4
11
5
3
8

output:

148626971

result:

ok single line: '148626971'

Test #13:

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

input:

750 66
3
5
3
11
11
9
9
4
7
8
3
4
4
5
11
9
1
6
9
6
7
8
11
7
9
7
1
10
3
8
10
6
3
4
8
11
9
6
1
11
1
8
7
7
2
9
5
5
6
1
8
10
10
9
5
11
3
9
10
6
1
6
3
8
8
3

output:

817964272

result:

ok single line: '817964272'

Test #14:

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

input:

750 66
2
8
1
1
7
11
4
8
5
6
3
11
11
5
3
2
1
6
3
6
6
5
2
8
11
6
6
7
8
1
5
11
6
8
2
3
7
10
10
6
6
11
7
5
6
6
5
9
7
3
4
4
10
4
6
4
3
9
6
6
11
2
4
6
6
11

output:

936531345

result:

ok single line: '936531345'

Test #15:

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

input:

750 66
4
6
11
1
6
9
7
1
5
4
5
6
2
8
1
2
11
6
5
3
1
6
9
8
5
9
6
2
5
1
5
3
8
6
8
5
7
4
8
1
11
11
10
8
4
6
5
10
7
8
8
8
3
9
1
8
2
9
7
5
3
1
1
11
7
4

output:

484040613

result:

ok single line: '484040613'

Test #16:

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

input:

750 66
4
9
10
7
10
11
3
7
1
6
11
4
2
11
5
5
1
2
9
7
8
3
5
8
5
6
11
6
1
11
8
8
9
6
6
9
9
7
11
11
3
7
8
10
8
9
9
5
8
8
9
7
7
11
8
6
1
10
1
11
11
11
3
5
11
8

output:

205283749

result:

ok single line: '205283749'

Test #17:

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

input:

10000 135
51
12
73
56
26
59
61
62
19
65
54
35
64
74
73
49
62
57
51
35
22
62
26
19
50
36
24
54
41
74
26
58
45
40
6
24
55
39
10
47
70
15
61
31
54
2
48
56
2
10
1
25
24
39
70
63
10
73
15
73
51
59
28
58
28
59
24
2
72
33
30
21
63
5
38
60
26
16
57
15
58
47
17
8
32
13
36
10
14
46
4
16
68
71
56
58
58
36
52
1...

output:

238689397

result:

ok single line: '238689397'

Test #18:

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

input:

10000 135
39
35
58
63
64
35
27
55
63
35
26
59
20
33
66
14
53
5
23
34
23
65
4
1
30
62
73
32
32
25
74
16
39
19
14
63
29
9
42
33
21
2
34
57
17
50
43
14
69
41
65
1
14
43
74
66
42
10
25
50
5
4
61
36
45
37
45
10
4
59
21
56
70
55
74
40
17
4
1
10
51
8
6
27
59
57
5
14
37
61
34
4
35
19
30
37
49
33
59
70
68
24...

output:

655049586

result:

ok single line: '655049586'

Test #19:

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

input:

10000 135
56
44
26
41
53
50
35
46
28
34
28
69
74
8
12
59
60
73
68
15
11
72
56
16
13
39
66
71
22
56
19
48
34
21
55
14
68
68
11
12
33
56
51
66
44
28
48
12
72
62
3
15
11
68
33
61
63
56
46
66
32
25
6
25
53
11
47
50
65
14
69
56
23
5
18
14
26
24
46
6
39
3
16
25
56
45
57
60
38
17
71
60
59
41
16
8
6
58
61
6...

output:

186140421

result:

ok single line: '186140421'

Test #20:

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

input:

10000 135
29
72
20
7
26
20
3
2
21
45
6
26
59
57
70
60
39
22
71
44
6
25
18
63
64
65
52
69
1
44
53
25
15
40
45
65
63
22
37
32
38
27
11
35
28
49
30
32
55
43
21
12
32
51
4
56
29
34
11
43
61
7
63
44
67
48
17
18
35
66
16
54
49
74
63
11
19
33
22
60
51
31
8
29
7
9
53
72
19
58
23
68
10
29
41
54
52
37
53
2
11...

output:

45969765

result:

ok single line: '45969765'

Test #21:

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

input:

10000 135
26
40
71
23
39
22
9
26
31
14
58
6
60
69
5
47
7
12
2
5
18
33
38
65
49
21
22
13
65
47
6
52
9
2
54
55
54
47
19
36
52
28
45
29
61
30
8
20
3
55
4
62
43
3
41
3
66
33
10
51
57
61
54
1
21
39
61
51
20
12
34
23
71
45
61
58
8
57
19
9
8
9
59
45
67
29
43
68
8
6
62
38
24
28
31
26
25
9
2
73
30
13
51
18
3...

output:

846150921

result:

ok single line: '846150921'

Test #22:

score: 0
Accepted
time: 56ms
memory: 7760kb

input:

1000000 5000
104
84
160
121
175
76
184
34
146
1
63
137
83
3
173
64
88
53
200
64
126
87
182
18
75
42
61
114
15
113
128
12
59
56
18
104
58
83
199
174
78
52
177
11
67
58
35
30
169
40
153
11
65
143
62
21
95
12
163
53
172
38
34
127
8
5
36
84
155
66
196
4
15
175
104
132
196
9
101
47
106
38
167
154
71
137
...

output:

333934562

result:

ok single line: '333934562'

Test #23:

score: 0
Accepted
time: 55ms
memory: 7828kb

input:

1000000 5000
11
139
142
56
4
3
161
180
91
159
66
62
11
37
106
29
140
167
120
53
121
89
195
31
174
172
142
91
155
86
54
143
150
7
141
191
119
56
131
75
119
103
11
104
129
37
90
100
138
135
14
102
186
179
40
3
92
7
78
171
38
123
29
82
98
32
147
162
29
77
109
31
139
27
167
131
44
196
170
90
75
197
109
...

output:

805474992

result:

ok single line: '805474992'

Test #24:

score: 0
Accepted
time: 59ms
memory: 7716kb

input:

1000000 5000
188
106
130
1
176
11
60
116
72
25
182
160
100
95
128
197
46
21
114
58
165
56
117
84
106
53
129
139
85
176
95
169
56
84
146
73
194
51
90
145
63
155
71
107
6
29
105
168
79
186
129
19
108
126
113
170
112
51
42
22
160
35
86
92
51
7
73
161
178
34
61
165
149
32
20
88
96
42
124
198
27
184
78
9...

output:

856609483

result:

ok single line: '856609483'

Test #25:

score: 0
Accepted
time: 51ms
memory: 7760kb

input:

1000000 5000
107
7
171
64
147
108
116
128
3
48
52
42
111
64
180
10
118
195
117
24
179
173
21
146
56
72
147
120
65
192
194
120
86
163
19
113
136
181
98
66
15
14
62
89
22
175
97
134
149
51
196
44
70
167
166
122
82
187
151
147
31
200
39
145
191
17
69
172
91
54
153
33
66
100
190
137
36
180
114
145
17
72...

output:

74206270

result:

ok single line: '74206270'

Test #26:

score: 0
Accepted
time: 55ms
memory: 7900kb

input:

1000000 5000
74
162
199
1
170
31
180
135
195
195
114
134
129
133
22
144
172
192
34
161
33
145
181
45
127
61
183
73
54
200
8
145
129
165
196
66
31
100
101
19
76
179
168
93
56
30
51
184
130
174
188
126
22
162
179
4
54
27
86
60
31
66
86
177
94
169
163
127
119
109
184
133
5
42
159
163
7
28
98
104
69
43
...

output:

149257141

result:

ok single line: '149257141'

Test #27:

score: 0
Accepted
time: 55ms
memory: 7896kb

input:

1000000 5000
18
135
156
36
66
7
44
10
34
104
63
156
16
12
141
196
84
134
160
185
110
142
200
136
37
52
30
150
154
138
10
120
15
95
169
110
167
17
144
40
157
76
151
90
107
183
87
185
72
143
143
83
22
50
165
86
105
130
174
195
142
184
10
80
169
183
62
100
134
26
14
133
118
156
2
69
34
152
105
121
144
...

output:

632175646

result:

ok single line: '632175646'

Test #28:

score: 0
Accepted
time: 55ms
memory: 7844kb

input:

1000000 5000
73
55
27
83
118
101
132
6
68
14
69
153
196
190
20
97
191
108
196
67
162
59
86
68
150
108
108
163
1
155
21
80
73
110
97
6
164
110
133
107
53
26
153
66
18
149
75
189
165
91
20
127
17
183
149
59
186
68
154
60
31
14
129
131
166
196
182
71
41
1
173
7
110
155
2
148
40
119
188
190
75
128
150
1...

output:

270910653

result:

ok single line: '270910653'

Test #29:

score: 0
Accepted
time: 55ms
memory: 7900kb

input:

1000000 5000
58
119
134
127
96
199
117
167
124
107
35
65
141
47
52
24
187
13
18
152
14
4
106
168
144
44
17
88
71
41
32
28
153
39
154
110
139
88
103
147
18
190
116
181
100
93
200
189
189
20
6
64
129
88
27
94
173
30
111
146
142
13
160
161
121
42
126
49
152
5
176
114
148
80
109
154
95
36
190
176
14
105...

output:

556724173

result:

ok single line: '556724173'

Test #30:

score: 0
Accepted
time: 55ms
memory: 7784kb

input:

1000000 5000
5
35
118
146
45
62
20
50
105
9
77
24
120
116
87
130
146
161
57
91
55
140
107
154
111
98
152
86
175
13
119
15
26
108
158
94
106
91
2
100
128
138
4
108
1
55
105
200
27
35
81
182
144
47
31
185
8
70
26
148
107
112
44
65
94
85
109
20
139
25
147
170
77
31
10
158
95
141
85
54
77
58
40
27
116
4...

output:

569427125

result:

ok single line: '569427125'

Test #31:

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

input:

750 66
1
1
3
2
5
1
5
1
4
2
4
4
2
7
1
9
7
4
4
1
7
10
1
5
5
2
1
7
3
2
10
2
6
8
1
2
4
4
3
4
3
7
4
7
3
2
2
6
3
1
4
9
7
6
2
1
2
5
1
6
3
2
2
2
4
1

output:

557711843

result:

ok single line: '557711843'

Test #32:

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

input:

750 66
8
9
1
1
4
2
7
2
5
2
1
1
7
1
10
2
1
3
5
5
3
4
10
1
5
1
1
7
4
2
9
1
3
3
1
1
2
1
2
1
8
2
5
11
4
1
1
2
11
7
1
1
8
4
1
4
8
4
7
1
4
3
2
6
1
2

output:

525639093

result:

ok single line: '525639093'

Test #33:

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

input:

750 66
5
2
7
1
4
5
5
2
4
1
1
7
2
4
1
5
7
1
2
4
4
4
6
8
3
4
1
6
3
2
9
2
1
2
5
1
3
3
8
3
2
9
3
2
2
8
5
10
1
1
3
3
1
6
4
2
3
11
6
1
2
3
4
2
7
2

output:

486590099

result:

ok single line: '486590099'

Test #34:

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

input:

750 66
3
2
1
8
4
1
2
2
2
3
1
1
2
1
5
2
8
7
4
5
1
4
1
3
1
7
2
1
4
5
1
3
2
8
1
2
2
2
2
1
1
2
3
4
2
1
6
7
6
2
1
1
1
2
2
6
1
3
10
3
1
5
9
4
1
6

output:

698145385

result:

ok single line: '698145385'

Test #35:

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

input:

750 66
3
4
9
2
2
3
1
5
1
3
3
6
1
7
3
2
2
4
4
5
2
2
1
2
8
1
5
7
2
2
5
4
1
1
3
1
6
5
5
2
4
5
6
3
7
3
3
3
1
5
1
4
4
3
6
4
4
1
8
1
1
6
9
1
8
1

output:

60567788

result:

ok single line: '60567788'

Test #36:

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

input:

750 66
1
3
7
5
3
3
1
4
1
1
1
4
8
1
2
1
1
5
1
5
6
2
3
5
4
8
4
4
2
3
5
2
3
5
8
1
5
1
1
5
5
7
2
1
6
6
1
3
3
1
1
1
5
4
1
2
2
4
4
2
4
5
11
1
3
3

output:

129540106

result:

ok single line: '129540106'

Test #37:

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

input:

10000 135
4
22
1
4
3
33
2
14
53
3
38
10
13
4
17
38
5
19
48
12
36
16
6
6
4
53
1
47
1
5
6
57
18
15
1
6
24
4
22
27
4
17
32
8
21
8
1
63
2
34
2
24
27
18
17
55
6
45
7
9
18
21
18
9
21
42
3
54
8
49
61
6
54
2
21
4
27
6
2
26
2
3
13
16
7
11
15
10
17
31
2
47
2
15
25
56
7
24
14
12
6
10
5
12
10
3
5
20
6
3
6
4
7
1...

output:

950985806

result:

ok single line: '950985806'

Test #38:

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

input:

10000 135
29
6
12
3
3
2
28
4
19
56
1
8
40
1
6
5
31
6
8
1
29
6
42
56
57
6
2
9
2
9
11
5
26
53
26
38
42
30
3
67
7
27
21
1
18
3
64
8
25
14
12
2
19
22
7
1
17
18
36
8
23
1
10
65
3
28
1
27
18
18
4
13
12
15
3
8
4
33
19
23
21
4
4
19
35
10
16
7
1
1
34
3
6
1
2
46
6
7
7
35
3
4
10
43
55
15
12
37
9
22
25
11
21
8
...

output:

156060910

result:

ok single line: '156060910'

Test #39:

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

input:

10000 135
21
16
13
24
15
45
8
51
4
31
13
44
35
5
10
41
52
6
41
2
3
28
30
1
23
4
7
2
19
40
2
29
40
6
14
14
25
6
1
11
31
19
20
1
4
22
29
9
4
1
7
63
10
21
2
33
6
10
4
1
35
12
56
26
6
10
5
5
29
23
45
3
5
4
62
7
24
16
29
7
24
9
5
3
20
13
39
15
17
10
2
40
3
3
20
64
44
16
28
3
23
52
2
35
3
5
1
22
5
4
10
6
...

output:

182793092

result:

ok single line: '182793092'

Test #40:

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

input:

10000 135
27
4
11
4
39
6
1
53
6
12
18
4
6
6
19
7
12
17
10
2
2
5
31
24
46
64
13
23
42
2
4
4
1
18
27
6
1
1
36
47
3
17
22
31
8
2
16
32
3
3
14
1
21
1
35
7
1
30
6
30
14
19
54
56
31
8
64
42
10
45
1
13
3
18
10
36
4
36
19
9
12
23
63
18
6
9
17
29
2
51
16
25
64
1
30
5
5
13
31
50
24
25
47
5
17
20
12
18
37
12
5...

output:

101235192

result:

ok single line: '101235192'

Test #41:

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

input:

10000 135
6
42
4
31
22
6
6
7
3
1
11
12
23
26
8
39
21
34
11
4
3
25
22
55
32
35
38
3
10
1
14
18
28
29
24
2
3
24
9
46
26
12
22
13
8
4
35
11
2
15
4
8
20
10
37
13
52
6
5
7
23
2
2
1
66
32
5
32
12
3
9
32
4
2
12
13
1
56
1
4
46
14
2
7
16
11
6
28
2
35
4
42
18
5
37
10
45
17
1
4
24
2
57
15
54
52
21
25
26
17
2
2...

output:

453204761

result:

ok single line: '453204761'

Test #42:

score: 0
Accepted
time: 52ms
memory: 7828kb

input:

1000000 5000
30
14
29
134
56
26
76
20
17
145
67
16
43
153
81
47
110
33
26
88
107
16
35
24
145
69
8
53
60
25
134
84
39
35
97
7
41
18
138
59
45
94
95
1
45
3
41
49
18
138
38
26
6
38
19
158
32
109
30
11
15
22
22
6
46
1
53
21
48
64
66
25
70
32
64
149
43
45
98
30
40
75
38
3
15
37
13
12
17
21
3
40
28
2
25
...

output:

31122794

result:

ok single line: '31122794'

Test #43:

score: 0
Accepted
time: 56ms
memory: 7720kb

input:

1000000 5000
3
126
49
65
95
108
126
40
27
5
82
172
40
131
57
6
46
7
5
71
50
28
45
88
5
5
16
116
17
63
22
34
2
37
50
1
51
11
47
123
1
25
65
33
12
168
74
30
11
17
71
4
100
76
96
16
10
17
140
3
21
34
104
90
5
102
110
55
87
29
57
56
22
22
40
12
3
5
16
99
24
34
6
71
105
15
36
68
22
47
51
150
73
68
39
2
3...

output:

683325494

result:

ok single line: '683325494'

Test #44:

score: 0
Accepted
time: 57ms
memory: 7780kb

input:

1000000 5000
46
89
127
4
25
40
94
106
38
32
104
14
31
33
107
135
108
75
10
97
1
57
182
15
77
2
52
69
5
7
8
22
6
14
89
25
10
106
7
19
40
54
24
126
5
17
64
62
52
7
150
16
73
29
116
69
72
11
19
38
22
76
41
7
18
32
47
87
2
1
28
117
12
22
13
60
41
57
105
105
80
3
89
83
19
24
9
8
71
7
60
160
76
166
11
34
...

output:

643337483

result:

ok single line: '643337483'

Test #45:

score: 0
Accepted
time: 52ms
memory: 7836kb

input:

1000000 5000
50
50
59
15
7
134
67
25
28
67
19
20
84
126
108
2
72
88
16
65
56
124
68
19
6
44
75
91
126
35
110
43
99
85
36
4
87
73
24
25
99
4
17
35
17
7
14
118
24
44
29
64
66
40
40
12
4
31
12
1
58
83
7
6
97
25
187
21
58
121
46
155
11
111
57
164
2
8
106
20
24
1
34
88
20
20
87
14
170
192
14
8
9
15
167
1...

output:

468754028

result:

ok single line: '468754028'

Test #46:

score: 0
Accepted
time: 57ms
memory: 7836kb

input:

1000000 5000
90
41
38
13
142
9
2
1
88
21
62
34
3
68
31
155
55
55
101
83
22
103
7
19
80
140
46
20
69
129
18
11
37
76
4
5
9
22
132
176
70
40
7
36
33
20
5
57
22
70
20
39
7
24
14
103
34
8
144
108
13
57
114
21
35
112
135
29
76
59
103
155
80
6
81
73
44
31
87
29
32
64
67
38
46
42
110
63
49
40
64
25
97
1
34...

output:

654872983

result:

ok single line: '654872983'

Test #47:

score: 0
Accepted
time: 56ms
memory: 7900kb

input:

1000000 5000
1
32
30
42
20
22
8
58
126
14
116
124
74
64
82
19
82
77
11
5
9
30
32
35
10
16
43
1
41
30
18
56
14
29
40
69
151
37
72
41
7
47
25
123
59
120
47
51
31
50
96
12
47
27
3
23
66
61
34
58
28
4
2
129
24
125
2
149
40
28
99
46
187
67
78
80
27
20
48
37
60
60
2
21
48
133
4
108
8
3
4
176
18
68
88
70
3...

output:

214931813

result:

ok single line: '214931813'

Test #48:

score: 0
Accepted
time: 53ms
memory: 7752kb

input:

1000000 5000
4
66
34
30
32
4
32
29
15
12
12
24
69
4
85
73
39
91
48
28
12
54
9
29
29
21
46
10
45
86
112
4
52
6
21
24
34
27
40
34
175
53
52
52
1
47
7
87
51
1
12
94
30
102
88
85
11
1
77
148
4
103
50
6
37
56
148
108
34
67
27
17
27
49
5
44
77
52
65
41
77
41
77
130
52
106
20
22
164
20
67
133
17
89
30
14
1...

output:

457872307

result:

ok single line: '457872307'

Test #49:

score: 0
Accepted
time: 52ms
memory: 7764kb

input:

1000000 5000
16
85
3
9
7
33
20
9
27
107
2
35
68
14
12
59
1
92
6
25
26
9
84
50
22
83
48
134
17
171
28
115
41
45
116
20
3
1
24
39
10
23
3
4
15
76
73
14
26
33
75
55
48
95
48
66
26
139
35
2
27
1
73
30
18
1
9
62
49
58
12
10
28
101
37
76
43
96
61
58
78
3
76
174
39
19
107
30
12
23
44
145
123
28
79
2
85
83
...

output:

878326417

result:

ok single line: '878326417'

Test #50:

score: 0
Accepted
time: 56ms
memory: 7748kb

input:

1000000 5000
2
14
87
104
52
53
143
157
88
5
6
111
26
105
70
4
164
173
37
102
93
55
9
14
52
113
117
67
17
86
1
89
1
6
33
26
53
29
20
58
11
34
16
21
67
18
12
12
40
6
2
3
47
32
34
89
57
41
50
87
75
2
121
143
13
1
55
41
9
1
62
6
57
5
34
7
3
40
21
14
150
25
19
2
25
31
156
108
4
78
25
98
60
59
42
110
11
3...

output:

900093672

result:

ok single line: '900093672'