-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCF_1198D.cpp
71 lines (62 loc) · 859 Bytes
/
CF_1198D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <iostream>
#include <algorithm>
using namespace std;
int n, arr[200001];
int s[200000], p[200000], x[200000];
bool changed[200001];
int maxX;
int main() {
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> arr[i];
}
int q;
cin >> q;
for (int i = q - 1; i >= 0; i--)
{
cin >> s[i];
if (s[i] == 1)
{
cin >> p[i] >> x[i];
}
else
{
cin >> x[i];
}
}
// last to first
for (int i = 0; i < q; i++)
{
// 1 p x
if (s[i] == 1)
{
int index = p[i];
int value = x[i];
if (changed[index])
{
continue;
}
changed[index] = true;
arr[index] = max(maxX, value);
}
// 2 x
else
{
int value = x[i];
maxX = max(maxX, value);
}
}
for (int i = 1; i <= n; i++)
{
if (changed[i])
{
cout << arr[i] << ' ';
}
else
{
cout << max(maxX, arr[i]) << ' ';
}
}
cout << endl;
}