CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 15:26:00 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=fa0923627a43e247333fcea0d2738d69f4bf4d5524ea53f76fb91a954a8c8f49a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22WC3wXMfnyYtKMp4P9E0hjdFERebb1m25%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cf5f937f9a8a2a-BLR
#include <iostream>#include <set>using namespace std;const int maxn = 2000 - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- using namespace std;
- const int maxn = 200005;
- const int INF = 2e9;
- int n, a[maxn];
- int segment_tree[3 * maxn];
- int merge_nodes(int A, int B) {
- return min(A, B);
- }
- void build_tree(int L = 0, int R = n - 1, int node = 1) {
- if(L == R) {
- segment_tree[node] = a[L];
- }
- else {
- int middle = (L + R) / 2;
- build_tree(L, middle, 2 * node);
- build_tree(middle + 1, R, 2 * node + 1);
- segment_tree[node] = merge_nodes(segment_tree[2 * node], segment_tree[2 * node + 1]);
- }
- }
- int query(int i, int j, int L = 0, int R = n - 1, int node = 1) {
- if(R < i or j < L) {
- return INF;
- }
- if(i <= L and R <= j) {
- return segment_tree[node];
- }
- int middle = (L + R) / 2;
- int left_side = query(i, j, L, middle, 2 * node);
- int right_side = query(i, j, middle + 1, R, 2 * node + 1);
- return merge_nodes(left_side, right_side);
- }
- int main() {
- ios_base::sync_with_stdio(false);
- int q;
- cin >> n >> q;
- for(int i = 0; i < n; i++) {
- cin >> a[i];
- }
- build_tree();
- for(int i = 0; i < q; i++) {
- int a, b;
- cin >> a >> b;
- a--; b--;
- cout << query(a, b) << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
✅⭐ Make huge profits on trading ✅ NEVER SEEN...
JavaScript | 2 sec ago | 0.24 KB
-
⭐✅ MAKE $2500 IN 15 MIN⭐⭐⭐ 6
JavaScript | 8 sec ago | 0.24 KB
-
⭐⭐⭐GMAIL Logs (2FA disabled)⭐⭐
Java | 10 sec ago | 0.10 KB
-
⭐✅ Marketplace Glitch ✅ Working ✅ NEVER SEEN...
JavaScript | 12 sec ago | 0.24 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ E
JavaScript | 19 sec ago | 0.24 KB
-
✅⭐ Make $2500 in 15 minutes ✅ NEVER SEEN BEFO...
JavaScript | 21 sec ago | 0.24 KB
-
Free Crypto Method (NEVER SEEN BEFORE)⭐⭐ M
JavaScript | 30 sec ago | 0.24 KB
-
⭐✅ Trading Profit Method ✅ NEVER SEEN BEFORE...
JavaScript | 40 sec ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand