CSES - Harjoituskisa 14.1.2018 - Results
Submission details
Task:Pizzeriat
Sender:Nanohenry
Submission time:2018-01-14 20:23:09 +0200
Language:C++
Status:READY
Result:11
Feedback
groupverdictscore
#1ACCEPTED11
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.05 s1details
#2ACCEPTED0.05 s1details
#3ACCEPTED0.05 s1details
#4--2details
#5--2details
#6--2details
#7--3details
#8--3details
#9--3details

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:32:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (long j = 1; j <= n; j++) {
                       ^

Code

#include <iostream>
#include <cmath>
#include <vector>

#define ULONG unsigned long

using namespace std;

int main() {
	ULONG n;
	ULONG q;
	cin >> n;
	cin >> q;
	ULONG p[n];
	for (ULONG i = 0; i < n; i++) {
		cin >> p[i];
	}
	vector<ULONG> res;
	for (ULONG i = 0; i < q; i++) {
		ULONG type;
		cin >> type;
		if (type == 1) {
			ULONG k;
			ULONG x;
			cin >> k;
			cin >> x;
			p[k - 1] = x;
		} else if (type == 2) {
			long k;
			cin >> k;
			ULONG l = 999999999;
			for (long j = 1; j <= n; j++) {
				//cout << "P: " << p[j - 1] << ", d: " << abs(j - k);
				ULONG ps = p[j - 1] + abs(j - k);
				//cout << "; " << ps << '\n';
				if (ps < l) {
					l = ps;
				}
			}
			res.push_back(l);
		}
	}
	for (ULONG i = 0; i < res.size(); i++) {
		cout << res[i] << '\n';
	}
	//while (1);
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

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

correct output
43
12
40
22
18
...

user output
43
12
40
22
18
...

Test 2

Group: 1

Verdict: ACCEPTED

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: ACCEPTED

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:

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

correct output
284
143
346
203
157
...

user output
(empty)

Test 5

Group: 2

Verdict:

input
100000 100000
76947 78386 71190 65478 90345 ...

correct output
459
297
128
234
204
...

user output
(empty)

Test 6

Group: 2

Verdict:

input
100000 100000
39277 33504 98385 58115 28655 ...

correct output
234
221
156
455
78
...

user output
(empty)

Test 7

Group: 3

Verdict:

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

correct output
427
409
352
39
388
...

user output
(empty)

Test 8

Group: 3

Verdict:

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

correct output
316
387
435
330
446
...

user output
(empty)

Test 9

Group: 3

Verdict:

input
100000 100000
87734 39225 78667 43704 17207 ...

correct output
228
83
176
428
273
...

user output
(empty)