hiho week 19 register

Ended

Participants:317

Verdict:Accepted
Score:100 / 100
Submitted:2014-11-08 21:16:56

Lang:G++

Edit
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
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 1000000 + 10;
int N, M, A[MAXN], T[MAXN * 10];
void buildTree(int p, int l, int r)
{
    if (l == r) {
        T[p] = A[r];
    } else {
        buildTree(p << 1, l, (l + r) >> 1);
        buildTree((p << 1) | 1, ((l + r) >> 1) + 1, r);
        T[p] = min(T[p << 1], T[(p << 1) | 1]);
    }
}
int query(int p, int l, int r, int x, int y)
{
    if (x <= l && r <= y) {
        return T[p];
    }
    if (r < x || y < l) {
        return 100000;
    }
    int m = (l + r) >> 1;
    return min(query(p << 1, l, m, x, y), query((p << 1) | 1, m + 1, r, x, y));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX