CSES - Harjoituskisa 14.1.2018 - Results
Submission details
Task:Pizzeriat
Sender:ArktinenKarpalo
Submission time:2018-01-14 20:21:56 +0200
Language:C++
Status:READY
Result:43
Feedback
groupverdictscore
#10
#2ACCEPTED43
#30
Test results
testverdicttimegroup
#10.04 s1details
#20.04 s1details
#30.04 s1details
#4ACCEPTED0.09 s2details
#5ACCEPTED0.08 s2details
#6ACCEPTED0.09 s2details
#70.09 s3details
#80.11 s3details
#90.10 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>=1; i--) {
		npo[i] = min(npo[i+1]+1, v[i]);
	}
	for(int i=0; i<q; i++) {
		cin >> a;
		if(a==2) {
			cin >> b;
		cout << min(npv[b], npo[b]) << "\n";
		} else {
			cin >> a >> b;
		}
	}
}

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
43
12
15
22
18
...

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
10
20
27
37
73
...

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
24
25
13
16
19
...

Test 4

Group: 2

Verdict: ACCEPTED

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

correct output
284
143
346
203
157
...

user output
284
143
346
203
157
...

Test 5

Group: 2

Verdict: ACCEPTED

input
100000 100000
76947 78386 71190 65478 90345 ...

correct output
459
297
128
234
204
...

user output
459
297
128
234
204
...

Test 6

Group: 2

Verdict: ACCEPTED

input
100000 100000
39277 33504 98385 58115 28655 ...

correct output
234
221
156
455
78
...

user output
234
221
156
455
78
...

Test 7

Group: 3

Verdict:

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

correct output
427
409
352
39
388
...

user output
427
409
352
39
388
...

Test 8

Group: 3

Verdict:

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

correct output
316
387
435
330
446
...

user output
316
387
435
330
446
...

Test 9

Group: 3

Verdict:

input
100000 100000
87734 39225 78667 43704 17207 ...

correct output
228
83
176
428
273
...

user output
228
83
176
428
273
...