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

Submission #857047

Source Code Expand

Copy
```#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define oo 987654321
#define INT long long
using namespace std;

int n, l, q, h[100010], a, b, cnt;
struct QUE{ int a, b, id, ans; } Q[100010];
bool cmp(QUE x, QUE y)
{
if( x.a == y.a ) return x.b < y.b;
return x.a < y.a;
}
bool cmp2(QUE x, QUE y)
{
return x.id < y.id;
}
int main()
{
scanf("%d", &n);
for(int i = 1 ; i <= n ; i++ )
scanf("%d", h+i);
scanf("%d%d", &l, &q);
for(int i = 0 ; i < q ; i++)
{
scanf("%d%d", &a, &b);
if( a > b ) swap(a, b);
Q[i].a = a, Q[i].b = b;
Q[i].id = i;
}
sort(Q, Q+q, cmp);
for(int i = 0, j ; i < q ; i = j )
{
int now = Q[i].a, cnt = 0;
vector<int> T;
for( j = i ; Q[i].a == Q[j].a ; j++ ) T.push_back(Q[j].b);
for(int c = 0 ; c < T.size() ; c++ )
{
while( now < T[c] )
{
now = (int)(upper_bound(h+1, h+n+1, h[now]+l) - h) - 1;
cnt++;
}
Q[i+c].ans = cnt;
}
}
sort(Q, Q+q, cmp2);
for(int i = 0 ; i < q ; i++ )
printf("%d\n", Q[i].ans);
return 0;
}
```

#### Submission Info

Submission Time 2016-08-28 22:34:50+0900 E - Tak and Hotels JKJeong C++14 (GCC 5.4.1) 200 1297 Byte TLE 3153 ms 2432 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:24:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
^
./Main.cpp:26:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", h+i);
^
./Main.cpp:27: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:30: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

Score / Max Score 0 / 0 200 / 200 0 / 500
Status
 AC × 1
 AC × 14
 AC × 17 TLE × 10
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 6 ms 256 KB
subtask1_04.txt AC 17 ms 256 KB
subtask1_05.txt AC 5 ms 256 KB
subtask1_06.txt AC 6 ms 256 KB
subtask1_07.txt AC 4 ms 256 KB
subtask1_08.txt AC 5 ms 256 KB
subtask1_09.txt AC 6 ms 256 KB
subtask1_10.txt AC 11 ms 256 KB
subtask1_11.txt AC 12 ms 256 KB
subtask1_12.txt AC 11 ms 256 KB
subtask1_13.txt AC 10 ms 256 KB
subtask2_01.txt TLE 3153 ms 2176 KB
subtask2_02.txt TLE 3153 ms 2176 KB
subtask2_03.txt TLE 3153 ms 2176 KB
subtask2_04.txt AC 74 ms 1664 KB
subtask2_05.txt TLE 3153 ms 1536 KB
subtask2_06.txt AC 112 ms 2432 KB
subtask2_07.txt TLE 3153 ms 2176 KB
subtask2_08.txt TLE 3153 ms 2176 KB
subtask2_09.txt TLE 3153 ms 2176 KB
subtask2_10.txt TLE 3153 ms 2176 KB
subtask2_11.txt TLE 3153 ms 2176 KB
subtask2_12.txt TLE 3153 ms 2176 KB
subtask2_13.txt AC 113 ms 2432 KB