CSES - Harjoituskisa 14.1.2018 - Results
Submission details
Task:Pizzeriat
Sender:ArktinenKarpalo
Submission time:2018-01-14 20:14:55 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.04 s1details
#20.04 s1details
#30.04 s1details
#40.09 s2details
#50.09 s2details
#60.10 s2details
#70.07 s3details
#80.09 s3details
#90.08 s3details

Code

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define M 1000000007

using namespace std;


ll n, q, a, b, c, f, npv[101010], npo[101010];
vector<ll> v;

int main() {
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	cin >> n >> q;
	v.push_back(0);
	for(int i=0; i<n; i++) {
		cin >> f;
		v.push_back(f);
	}
	npv[1] = v[1];
	for(int i=2; i<n; i++) {
		npv[i] = min(npv[i-1]+1, v[i]);
	}
	npo[n] = v[n];
	for(int i=n-1; i>=0; i--) {
		npo[i] = min(npo[i+1]+1, v[i]);
	}
	for(int i=0; i<q; i++) {
		cin >> b;
		cout << min(npv[b], npo[b]) << "\n";
	}
}

Test details

Test 1

Group: 1

Verdict:

input
1000 1000
720 271 760 576 363 23 368 995...

correct output
43
12
40
22
18
...

user output
28
7
33
28
14
...

Test 2

Group: 1

Verdict:

input
1000 1000
720 18 984 261 344 257 686 441...

correct output
10
20
27
37
73
...

user output
18
10
18
20
18
...

Test 3

Group: 1

Verdict:

input
1000 1000
120 764 890 848 949 59 894 916...

correct output
24
25
13
16
19
...

user output
19
24
20
43
7
...

Test 4

Group: 2

Verdict:

input
100000 100000
11763 43585 3126 3787 79765 64...

correct output
284
143
346
203
157
...

user output
392
284
392
143
392
...

Test 5

Group: 2

Verdict:

input
100000 100000
76947 78386 71190 65478 90345 ...

correct output
459
297
128
234
204
...

user output
453
459
453
297
453
...

Test 6

Group: 2

Verdict:

input
100000 100000
39277 33504 98385 58115 28655 ...

correct output
234
221
156
455
78
...

user output
188
234
188
221
188
...

Test 7

Group: 3

Verdict:

input
100000 100000
46508 6952 22836 54480 91235 2...

correct output
427
409
352
39
388
...

user output
309
335
336
308
427
...

Test 8

Group: 3

Verdict:

input
100000 100000
15918 8771 36223 76330 39229 7...

correct output
316
387
435
330
446
...

user output
203
316
204
133
363
...

Test 9

Group: 3

Verdict:

input
100000 100000
87734 39225 78667 43704 17207 ...

correct output
228
83
176
428
273
...

user output
451
149
435
450
228
...