AtCoder Regular Contest 004

Submission #4168839

Source codeソースコード

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> x = new ArrayList<>();
        List<Integer> y = new ArrayList<>();
        IntStream.range(0, n).forEach(i -> {
            x.add(sc.nextInt());
            y.add(sc.nextInt());
        });

        double maxLen = 0;
        for (int i = 0; i < x.size(); i++) {
            for (int j = i + 1; j < x.size(); j++) {
                double len = Math.sqrt(Math.pow(x.get(j) - x.get(i), 2)
                        + Math.pow(y.get(j) - y.get(i), 2));
                if (i == 0 && j == 1 || maxLen < len) {
                    maxLen = len;
                }
            }
        }
        System.out.println(maxLen);
    }

}

Submission

Task問題 A - 2点間距離の最大値 ( The longest distance )
User nameユーザ名 wkodate
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 934 Byte
File nameファイル名
Exec time実行時間 231 ms
Memory usageメモリ使用量 28372 KB

Test case

Set

Set name Score得点 / Max score Cases
All 100 / 100 00_max.txt,00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,00_sample_04.txt,00_sample_05.txt,01_rnd_00.txt,01_rnd_01.txt,01_rnd_02.txt,01_rnd_03.txt,01_rnd_04.txt,01_rnd_05.txt,01_rnd_06.txt,01_rnd_07.txt,01_rnd_08.txt,01_rnd_09.txt,01_rnd_10.txt,01_rnd_11.txt,01_rnd_12.txt,01_rnd_13.txt,01_rnd_14.txt,01_rnd_15.txt,01_rnd_16.txt,01_rnd_17.txt,01_rnd_18.txt,01_rnd_19.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_max.txt AC 231 ms 26952 KB
00_sample_01.txt AC 170 ms 24660 KB
00_sample_02.txt AC 180 ms 26832 KB
00_sample_03.txt AC 172 ms 24400 KB
00_sample_04.txt AC 183 ms 26580 KB
00_sample_05.txt AC 177 ms 26708 KB
01_rnd_00.txt AC 184 ms 26832 KB
01_rnd_01.txt AC 183 ms 26324 KB
01_rnd_02.txt AC 196 ms 26832 KB
01_rnd_03.txt AC 183 ms 24404 KB
01_rnd_04.txt AC 184 ms 26828 KB
01_rnd_05.txt AC 184 ms 24404 KB
01_rnd_06.txt AC 194 ms 24660 KB
01_rnd_07.txt AC 186 ms 26828 KB
01_rnd_08.txt AC 185 ms 24268 KB
01_rnd_09.txt AC 183 ms 26452 KB
01_rnd_10.txt AC 180 ms 24660 KB
01_rnd_11.txt AC 192 ms 26836 KB
01_rnd_12.txt AC 185 ms 24268 KB
01_rnd_13.txt AC 182 ms 24532 KB
01_rnd_14.txt AC 188 ms 23380 KB
01_rnd_15.txt AC 184 ms 28372 KB
01_rnd_16.txt AC 190 ms 24908 KB
01_rnd_17.txt AC 190 ms 26964 KB
01_rnd_18.txt AC 185 ms 24652 KB
01_rnd_19.txt AC 185 ms 26580 KB