forked from ngthanhtrung23/CompetitiveProgramming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB.cpp
More file actions
72 lines (68 loc) · 1.41 KB
/
B.cpp
File metadata and controls
72 lines (68 loc) · 1.41 KB
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
72
/**
* author: tourist
* created: 30.07.2019 17:49:26
**/
#include "bits/stdc++.h"
using namespace std;
inline int ReadInt()
{
char c;
while (c = getchar(), c < '0' || c > '9');
int x = c - '0';
while (c = getchar(), c >= '0' && c <= '9')
x = x * 10 + c - '0';
return x;
}
inline void WriteInt(int x)
{
int p = 1;
for (int temp = x / 10; temp > 0; temp /= 10)
p *= 10;
for (; p > 0; x %= p, p /= 10)
putchar(x / p + '0');
}
int main() {
int n = ReadInt();
vector<int> a(n);
for (int i = 0; i < n; i++) {
a[i] = ReadInt();
}
int tt = ReadInt();
vector<int> op(tt);
vector<int> who(tt);
vector<int> val(tt);
for (int i = 0; i < tt; i++) {
op[i] = ReadInt();
if (op[i] == 1) {
who[i] = ReadInt();
val[i] = ReadInt();
--who[i];
} else {
val[i] = ReadInt();
}
}
vector<int> res(n, -1);
int mx = -1;
for (int i = tt - 1; i >= 0; i--) {
if (op[i] == 1) {
if (res[who[i]] == -1) {
res[who[i]] = max(val[i], mx);
}
} else {
mx = max(mx, val[i]);
}
}
for (int i = 0; i < n; i++) {
if (res[i] == -1) {
res[i] = max(a[i], mx);
}
}
for (int i = 0; i < n; i++) {
if (i > 0) {
putchar(' ');
}
WriteInt(res[i]);
}
putchar('\n');
return 0;
}