Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma GCC target("avx2")
- #pragma GCC optimize("O3")
- #include "bits/stdc++.h"
- using namespace std;
- namespace IO {
- const int BUFSIZE = 1<<14;
- char buf[BUFSIZE + 1], *inp = buf;
- bool reacheof;
- char get_char() {
- if (!*inp && !reacheof) {
- memset(buf, 0, sizeof buf);
- int tmp = fread(buf, 1, BUFSIZE, stdin);
- if (tmp != BUFSIZE) reacheof = true;
- inp = buf;
- }
- return *inp++;
- }
- template<typename T>
- T get() {
- int neg = 0;
- T res = 0;
- char c = get_char();
- while (!std::isdigit(c) && c != '-' && c != '+') c = get_char();
- if (c == '+') { neg = 0; }
- else if (c == '-') { neg = 1; }
- else res = c - '0';
- c = get_char();
- while (std::isdigit(c)) {
- res = res * 10 + (c - '0');
- c = get_char();
- }
- return neg ? -res : res;
- }
- };
- const int MN = 100111;
- const int INF = 1000111000;
- int a[MN];
- int main() {
- int n = IO::get<int>();
- for (int i = 1; i <= n; i++) {
- a[i] = IO::get<int>();
- }
- int q = IO::get<int>();
- while (q--) {
- int typ = IO::get<int>();
- int x = IO::get<int>();
- int y = IO::get<int>();
- if (typ == 1) a[x] = y;
- else {
- long long max_val = -INF;
- for (int i = x; i <= y; i++) {
- max_val = (max_val < a[i]) ? a[i] : max_val;
- }
- cout << max_val << '\n';
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement