Submission #10044264
Source Code Expand
from bisect import * n, d = map(int, input().split()) x = list(map(int, input().split())) ans = 0 for i in range(1, n-1): left = x[i] - d right = x[i] + d ans += (i - bisect_left(x, left)) * (bisect_right(x, right) - i - 1) for i in range(n-2): right = x[i] + d option = bisect_right(x, right) - i - 1 ans -= option*(option-1)//2 print(ans)
Submission Info
Submission Time | |
---|---|
Task | C - 徒歩圏内 |
User | macaroni |
Language | Python (3.4.3) |
Score | 400 |
Code Size | 382 Byte |
Status | AC |
Exec Time | 273 ms |
Memory | 14252 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 260 ms | 14252 KB |
02.txt | AC | 243 ms | 14252 KB |
03.txt | AC | 248 ms | 14252 KB |
04.txt | AC | 251 ms | 14252 KB |
05.txt | AC | 246 ms | 14252 KB |
06.txt | AC | 256 ms | 14252 KB |
07.txt | AC | 248 ms | 14060 KB |
08.txt | AC | 223 ms | 12336 KB |
09.txt | AC | 17 ms | 3064 KB |
10.txt | AC | 263 ms | 14052 KB |
11.txt | AC | 273 ms | 14252 KB |
12.txt | AC | 245 ms | 14252 KB |
sample-01.txt | AC | 17 ms | 3064 KB |
sample-02.txt | AC | 17 ms | 3064 KB |
sample-03.txt | AC | 17 ms | 3064 KB |
sample-04.txt | AC | 18 ms | 3064 KB |