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

Submission #923280

Source Code Expand

Copy
```#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
#define mod 1000000007
#define INF 0x7fffffffff
#define N 300100
#define endl '\n'
int a[110000],dp[110000][25];
int main()
{
int n,m,L;
scanf("%d",&n);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
scanf("%d%d",&L,&m);
for(int i=1;i<=n;i++) dp[i][0]=upper_bound(a+i+1,a+1+n,a[i]+L)-a-1;
for(int j=0;j<18;j++)
for(int i=1;i<=n;i++)
dp[i][j+1]=dp[dp[i][j]][j];
while(m--)
{
int l,r;
scanf("%d%d",&l,&r);
if(l>r) swap(l,r);
int ans=1;
for(int i=17;i>=0;i--)
{
if(dp[l][i]<r) ans+=(1<<i),l=dp[l][i];
}
cout<<ans<<endl;
}
return 0;
}
```

#### Submission Info

Submission Time 2016-10-13 11:30:13+0900 E - Tak and Hotels mirac1e C++14 (GCC 5.4.1) 700 865 Byte AC 84 ms 11008 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:18:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.cpp:19:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
^
./Main.cpp:20:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&L,&m);
^
./Main.cpp:28:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&l,&r);
^
```

#### Judge Result

Score / Max Score 0 / 0 200 / 200 500 / 500
Status
 AC × 1
 AC × 14
 AC × 27
Set Name Test Cases
Sample example_01.txt
Case Name Status Exec Time Memory
example_01.txt AC 3 ms 256 KB
subtask1_01.txt AC 3 ms 256 KB
subtask1_02.txt AC 3 ms 256 KB
subtask1_03.txt AC 3 ms 384 KB
subtask1_04.txt AC 3 ms 384 KB
subtask1_05.txt AC 3 ms 384 KB
subtask1_06.txt AC 3 ms 256 KB
subtask1_07.txt AC 3 ms 256 KB
subtask1_08.txt AC 3 ms 384 KB
subtask1_09.txt AC 3 ms 384 KB
subtask1_10.txt AC 3 ms 384 KB
subtask1_11.txt AC 3 ms 384 KB
subtask1_12.txt AC 3 ms 384 KB
subtask1_13.txt AC 3 ms 384 KB
subtask2_01.txt AC 76 ms 10880 KB
subtask2_02.txt AC 84 ms 11008 KB
subtask2_03.txt AC 77 ms 10752 KB
subtask2_04.txt AC 41 ms 7040 KB
subtask2_05.txt AC 51 ms 7168 KB
subtask2_06.txt AC 62 ms 10624 KB
subtask2_07.txt AC 79 ms 10880 KB
subtask2_08.txt AC 84 ms 11008 KB
subtask2_09.txt AC 84 ms 11008 KB
subtask2_10.txt AC 83 ms 11008 KB
subtask2_11.txt AC 80 ms 10112 KB
subtask2_12.txt AC 61 ms 11008 KB
subtask2_13.txt AC 64 ms 10624 KB