Contest Duration: - (local time) (100 minutes) Back to Home

Submission #856166

Source Code Expand

Copy
```#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define rsp(it,s) for(set<int>::iterator it=s.begin();it!=s.end();it++)
#define mod 1000000000
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define Lson L, mid, rt<<1
#define Rson mid+1, R, rt<<1|1
const int maxn=1e5+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p;p=p*p;q>>=1;}return f;}
int n,m,k,t,l[maxn],r[maxn];
ll a[maxn],p;
void init()
{
for(int i=0;i<=n-1;i++)
{
r[i]=lower_bound(a,a+n,a[i]+p)-a;
if(r[i]==n||a[r[i]]>a[i]+p)r[i]--;
l[i]=lower_bound(a,a+n,a[i]-p)-a;
}
}
int main()
{
int i,j;
scanf("%d",&n);
rep(i,0,n-1)scanf("%lld",&a[i]);
scanf("%lld",&p);
init();
int q;
scanf("%d",&q);
while(q--)
{
int b,c,ans=0;
scanf("%d%d",&b,&c);
b--,c--;
if(b<c)
{
ans=0;
while(b<c)ans++,b=r[b];
}
else
{
ans=0;
while(b>c)ans++,b=l[b];
}
printf("%d\n",ans);
}
//system("Pause");
return 0;
}
```

#### Submission Info

Submission Time 2016-08-28 21:49:55+0900 E - Tak and Hotels mxzf0213 C++14 (GCC 5.4.1) 200 1580 Byte TLE 3157 ms 2304 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:47:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:48:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
rep(i,0,n-1)scanf("%lld",&a[i]);
^
./Main.cpp:49:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&p);
^
./Main.cpp:52:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&q);
^
./Main.cpp:56:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&b,&c);
...```

#### Judge Result

Score / Max Score 0 / 0 200 / 200 0 / 500
Status
 AC × 1
 AC × 14
 AC × 21 TLE × 6
Set Name Test Cases
Sample example_01.txt
Case Name Status Exec Time Memory
example_01.txt AC 4 ms 256 KB
subtask1_01.txt AC 4 ms 256 KB
subtask1_02.txt AC 4 ms 256 KB
subtask1_03.txt AC 5 ms 256 KB
subtask1_04.txt AC 6 ms 256 KB
subtask1_05.txt AC 5 ms 256 KB
subtask1_06.txt AC 5 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 5 ms 256 KB
subtask1_09.txt AC 7 ms 256 KB
subtask1_10.txt AC 6 ms 256 KB
subtask1_11.txt AC 6 ms 256 KB
subtask1_12.txt AC 6 ms 256 KB
subtask1_13.txt AC 6 ms 256 KB
subtask2_01.txt AC 1681 ms 2304 KB
subtask2_02.txt TLE 3157 ms 1920 KB
subtask2_03.txt AC 626 ms 2176 KB
subtask2_04.txt AC 57 ms 1408 KB
subtask2_05.txt AC 902 ms 1536 KB
subtask2_06.txt AC 81 ms 2048 KB
subtask2_07.txt AC 2275 ms 2304 KB
subtask2_08.txt TLE 3157 ms 2048 KB
subtask2_09.txt TLE 3153 ms 2048 KB
subtask2_10.txt TLE 3156 ms 2048 KB
subtask2_11.txt TLE 3157 ms 1920 KB
subtask2_12.txt TLE 3153 ms 1792 KB
subtask2_13.txt AC 83 ms 2048 KB