MSBOP 2015 Round3 register

Ended

Participants:978

Verdict:AC | TLE
Submitted:2015-05-09 15:43:49

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 <cstring>
#include <algorithm>
#define rep(i,s,t) for (int i = s; i <= t; ++i)
#define per(i,s,t) for (int i = s; i >= t; --i)
using namespace std;
int n, Q;
int a[200010];
char ch;
int Cases;
inline void read(int &x){
    for (ch = getchar(); ch < '0' || ch > '9'; ch = getchar());
    x = ch-48; for (ch = getchar(); ch >= '0' && ch <= '9'; ch = getchar()) x = x*10+ch-48;
}
inline void Run(){
    read(n); read(Q);
    rep(i,1,n) read(a[i]);
    int l, r, k, ans;
    while (Q--){
        read(l); read(r); read(k);
        ans = 1000000000;
        rep(i,l,r) ans = min(ans, abs(k-a[i]));
        printf("%d\n", ans);
    }
}
int main(){
    read(Cases);
    rep(Case,1,Cases){
        printf("Case #%d:\n", Case);
        Run();
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX