CSES - Harjoituskisa 14.1.2018 - Results
Submission details
Task:Pizzeriat
Sender:Kuha
Submission time:2018-01-14 19:21:32 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.06 s1details
#20.05 s1details
#30.04 s1details
#40.44 s2details
#50.42 s2details
#60.39 s2details
#70.44 s3details
#80.46 s3details
#90.52 s3details

Code

#include <bits/stdc++.h>

#define N (1<<17)
#define ll long long
#define ld long double
#define M 1000000007
#define INF 0x5ADFACE5
#define LINF 0x51DEEFFEC7C0DECALL
#define pii pair<int, int>
#define pll pair<long long, long long>
#define F first
#define S second

using namespace std;

int p[N];
multiset<int> ls;
multiset<int> rs;

int main () {
	int n, q;
	cin>>n>>q;
	for (int i = 1; i <= n; i++) cin>>p[i];
	for (int i = 1; i <= n; i++) {
		rs.insert(i + p[i]);
		ls.insert(i - p[i]);
	}
	while (q --> 0) {
		int t;
		cin>>t;
		if (t == 1) {
			int a, b;
			cin>>a>>b;
			rs.erase(rs.lower_bound(a + p[a]));
			ls.erase(ls.lower_bound(a - p[a]));
			p[a] = b;
			rs.insert(a + p[a]);
			ls.insert(a - p[a]);
		} else {
			int i;
			cin>>i;
			int ans = 0;
			auto it = rs.lower_bound(i);
			if (it != rs.end()) ans = (*it) - i;
			//cout<<(*it)<<" ";
			auto it2 = ls.upper_bound(i);
			if (it2 != ls.begin()) {
				--it2;
				ans = max(i - (*it2), ans);
				//cout<<(*it2)<<" ";
			}
			cout<<ans<<endl;
		}
	}
}

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
2
8
0
6
11
...

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
6
10
2
3
10
...

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
5
6
1
4
10
...

Test 4

Group: 2

Verdict:

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

correct output
284
143
346
203
157
...

user output
3
11
4
48
1
...

Test 5

Group: 2

Verdict:

input
100000 100000
76947 78386 71190 65478 90345 ...

correct output
459
297
128
234
204
...

user output
5
1
8
5
0
...

Test 6

Group: 2

Verdict:

input
100000 100000
39277 33504 98385 58115 28655 ...

correct output
234
221
156
455
78
...

user output
0
15
59
3
4
...

Test 7

Group: 3

Verdict:

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

correct output
427
409
352
39
388
...

user output
2
9
6
15
3
...

Test 8

Group: 3

Verdict:

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

correct output
316
387
435
330
446
...

user output
2
14
2
7
1
...

Test 9

Group: 3

Verdict:

input
100000 100000
87734 39225 78667 43704 17207 ...

correct output
228
83
176
428
273
...

user output
5
10
0
9
0
...