Submission #2601216


Source Code Expand

Copy
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    int N = Integer.parseInt(sc.next());
    int D = Integer.parseInt(sc.next());
    
    long X[] = new long[N];
    for (int i = 0; i < N; i++) {
      X[i] = Long.parseLong(sc.next());
    }
    
    long ans = 0;
    for (int i = 0; i < N - 2; i++) {
      for (int k = i + 2; k < N; k++) {
        if (X[k] - X[i] > 2 * D) {
          break;
        } else if (X[k] - X[i] <= D) {
          continue;
        }
        for (int j = i + 1; j < k; j++) {
          if (X[k] - X[j] <= D && X[j] - X[i] <= D) {
            ans++;
          }
        }
      }
    }
    System.out.println(ans);
  }
}

Submission Info

Submission Time
Task C - 徒歩圏内
User asuma
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 779 Byte
Status
Exec Time 2165 ms
Memory 48716 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample-01.txt, sample-02.txt, sample-03.txt, sample-04.txt
All 0 / 400 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 2109 ms 46912 KB
02.txt 363 ms 43652 KB
03.txt 2109 ms 45588 KB
04.txt 2109 ms 41900 KB
05.txt 401 ms 48060 KB
06.txt 2109 ms 45528 KB
07.txt 2109 ms 45184 KB
08.txt 335 ms 45992 KB
09.txt 88 ms 19924 KB
10.txt 2165 ms 48716 KB
11.txt 2109 ms 43016 KB
12.txt 427 ms 47256 KB
sample-01.txt 90 ms 21716 KB
sample-02.txt 89 ms 21844 KB
sample-03.txt 113 ms 20180 KB
sample-04.txt 89 ms 21716 KB