MSBOP 2015 Round3 register

Ended

Participants:978

Verdict:AC | TLE
Submitted:2015-05-09 14:47:57

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
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int a[200005];
int main(){
    int t, n, cas, l, r, k, q;
    cin >> t;
    cas = t;
    while (t--){
        cout << "Case #" << cas - t << ":" << endl;
        scanf("%d%d", &n, &q);
        for (int i = 1; i <= n; i++){
            scanf("%d", &a[i]);
        }
        for (int i = 0; i < q; i++){
            cin >> l >> r >> k;
            int min = 1e9 + 7;
            for (int j = l; j <= r; j++){
                if (abs(a[j] - k) < min) min = abs(a[j] - k);
            }
            cout << min << endl;
        }
    }
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX