MSBOP 2015 Round3 register

Ended

Participants:978

Verdict:AC | TLE
Submitted:2015-05-09 15:31: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
28
29
30
31
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define LL long long
using namespace std;
const int N = 200010;
int a[N];
int main()
{
    #ifdef LOCAL
    freopen("in","r",stdin);
    #endif
    int T,n,q,cas=1;
    scanf("%d", &T);
    while(T--) {
        printf("Case #%d:\n",cas++);
        scanf("%d%d",&n,&q);
        for(int i=1;i<=n;i++)scanf("%d",&a[i]);
        for(int i=1;i<=q;i++)
        {
            int l,r,k;
            scanf("%d%d%d",&l,&r,&k);
            int ans=0x3f3f3f3f;
            for(int j=l;j<=r;j++)
            {
                ans=min(ans,abs(k-a[j]));
            }
            printf("%d\n",ans);
        }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX