-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathd.cc
More file actions
35 lines (32 loc) · 737 Bytes
/
d.cc
File metadata and controls
35 lines (32 loc) · 737 Bytes
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
// https://codeforces.com/contest/1199/problem/D
#include <bits/stdc++.h>
using namespace std;
using ii = tuple<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
int main() {
int n, q;
int t, p, x;
cin >> n;
vi a(n), z(n, -1);
for (int i = 0; i < n; i++) cin >> a[i];
vii b;
cin >> q;
for (int i = 0; i < q; i++) {
cin >> t;
if (t == 1) cin >> p;
else p = 0;
cin >> x;
b.push_back({p, x});
}
int l = -1;
for (int i = q - 1; i >= 0; i--) {
tie(p, x) = b[i];
if (!p) l = max(l, x);
else if (z[p - 1] == -1) z[p - 1] = max(x, l);
}
for (int i = 0; i < n; i++)
if (z[i] == -1) z[i] = max(l, a[i]);
for (int i = 0; i < n; i++)
cout << z[i] <<" \n"[i == n-1];
}