Submission #860013
Source Code Expand
Copy
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#define MOD 1000000007
#define oo 987654321
#define INT long long
using namespace std;
int n, l, q, h[100010], dt[100010][17], a, b, now;
int main()
{
scanf("%d", &n);
for(int i = 1 ; i <= n ; i++ )
scanf("%d", h+i);
scanf("%d%d", &l, &q);
for(int i = 1 ; i <= n ; i++ )
dt[i][0] = (int)(upper_bound(h+1, h+n+1, h[i]+l)-h) - 1;
for(int j = 1 ; j < 17 ; j++ )
for(int i = 1 ; i <= n ; i++ )
dt[i][j] = dt[dt[i][j-1]][j-1];
while( q-- )
{
scanf("%d%d", &a, &b);
if( a > b ) swap(a, b);
int cnt = 0;
while( a < b )
{
for(int i = 0 ; i < 17 ; i++ )
if( dt[a][i] > b ){ now = dt[a][i-1]; cnt+=(1<<(i-1)); break; }
a = now;
}
printf("%d\n", cnt);
}
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Tak and Hotels |
User |
JKJeong |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
939 Byte |
Status |
WA |
Exec Time |
3157 ms |
Memory |
8448 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:14:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:16:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", h+i);
^
./Main.cpp:17:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &l, &q);
^
./Main.cpp:25:30: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &a, &b);
^
Judge Result
Set Name |
Sample |
Subtask1 |
All |
Score / Max Score |
0 / 0 |
0 / 200 |
0 / 500 |
Status |
|
|
|
Set Name |
Test Cases |
Sample |
example_01.txt |
Subtask1 |
example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt |
All |
example_01.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask1_13.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask2_13.txt |
Case Name |
Status |
Exec Time |
Memory |
example_01.txt |
AC |
4 ms |
256 KB |
subtask1_01.txt |
TLE |
3153 ms |
256 KB |
subtask1_02.txt |
TLE |
3153 ms |
256 KB |
subtask1_03.txt |
WA |
5 ms |
256 KB |
subtask1_04.txt |
TLE |
3153 ms |
256 KB |
subtask1_05.txt |
TLE |
3157 ms |
256 KB |
subtask1_06.txt |
TLE |
3156 ms |
256 KB |
subtask1_07.txt |
TLE |
3153 ms |
256 KB |
subtask1_08.txt |
TLE |
3153 ms |
384 KB |
subtask1_09.txt |
WA |
5 ms |
384 KB |
subtask1_10.txt |
TLE |
3153 ms |
256 KB |
subtask1_11.txt |
TLE |
3153 ms |
256 KB |
subtask1_12.txt |
TLE |
3153 ms |
256 KB |
subtask1_13.txt |
TLE |
3157 ms |
256 KB |
subtask2_01.txt |
WA |
136 ms |
8448 KB |
subtask2_02.txt |
TLE |
3157 ms |
7296 KB |
subtask2_03.txt |
WA |
142 ms |
8448 KB |
subtask2_04.txt |
TLE |
3157 ms |
4864 KB |
subtask2_05.txt |
WA |
91 ms |
5632 KB |
subtask2_06.txt |
TLE |
3157 ms |
7680 KB |
subtask2_07.txt |
WA |
136 ms |
8320 KB |
subtask2_08.txt |
TLE |
3157 ms |
7296 KB |
subtask2_09.txt |
WA |
142 ms |
8064 KB |
subtask2_10.txt |
TLE |
3154 ms |
7296 KB |
subtask2_11.txt |
TLE |
3154 ms |
7040 KB |
subtask2_12.txt |
TLE |
3154 ms |
7296 KB |
subtask2_13.txt |
TLE |
3154 ms |
7424 KB |