CSES - Harjoituskisa 14.1.2018 - Results
Submission details
Task:Kasihymiö
Sender:Nanohenry
Submission time:2018-01-14 20:03:23 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
Test results
testverdicttimegroup
#1--1details
#20.10 s1details
#3--1details
#40.04 s1details
#50.05 s1details
#6--2details
#70.10 s2details
#8--2details
#90.04 s2details
#100.03 s2details

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) {
			ULONG k;
			cin >> k;
			ULONG l = 9999999999999;
			for (ULONG j = 0; j < n; j++) {
				ULONG ps = p[j] + abs((j + 1) - k);
				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:

input
888888888888888888888888888888...

correct output
0

user output
(empty)

Test 2

Group: 1

Verdict:

input
))))))))))))))))))))))))))))))...

correct output
0

user output
(empty)

Test 3

Group: 1

Verdict:

input
888888888888888888888888888888...

correct output
250000

user output
(empty)

Test 4

Group: 1

Verdict:

input
8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)...

correct output
125250

user output
(empty)

Test 5

Group: 1

Verdict:

input
8)88))))88))8)))8))8))888))888...

correct output
127050

user output
(empty)

Test 6

Group: 2

Verdict:

input
888888888888888888888888888888...

correct output
0

user output
(empty)

Test 7

Group: 2

Verdict:

input
))))))))))))))))))))))))))))))...

correct output
0

user output
(empty)

Test 8

Group: 2

Verdict:

input
888888888888888888888888888888...

correct output
250000000000

user output
(empty)

Test 9

Group: 2

Verdict:

input
8)8)8)8)8)8)8)8)8)8)8)8)8)8)8)...

correct output
125000250000

user output
(empty)

Test 10

Group: 2

Verdict:

input
888)888))8)88)8))88)888)88))8)...

correct output
125162819188

user output
(empty)