Submission #4168839


Source Code Expand

Copy
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 Info

Submission Time
Task A - 2点間距離の最大値 ( The longest distance )
User wkodate
Language Java8 (OpenJDK 1.8.0)
Score 100
Code Size 934 Byte
Status
Exec Time 231 ms
Memory 28372 KB

Judge Result

Set Name Score / Max Score Test 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
Case Name Status Exec Time Memory
00_max.txt 231 ms 26952 KB
00_sample_01.txt 170 ms 24660 KB
00_sample_02.txt 180 ms 26832 KB
00_sample_03.txt 172 ms 24400 KB
00_sample_04.txt 183 ms 26580 KB
00_sample_05.txt 177 ms 26708 KB
01_rnd_00.txt 184 ms 26832 KB
01_rnd_01.txt 183 ms 26324 KB
01_rnd_02.txt 196 ms 26832 KB
01_rnd_03.txt 183 ms 24404 KB
01_rnd_04.txt 184 ms 26828 KB
01_rnd_05.txt 184 ms 24404 KB
01_rnd_06.txt 194 ms 24660 KB
01_rnd_07.txt 186 ms 26828 KB
01_rnd_08.txt 185 ms 24268 KB
01_rnd_09.txt 183 ms 26452 KB
01_rnd_10.txt 180 ms 24660 KB
01_rnd_11.txt 192 ms 26836 KB
01_rnd_12.txt 185 ms 24268 KB
01_rnd_13.txt 182 ms 24532 KB
01_rnd_14.txt 188 ms 23380 KB
01_rnd_15.txt 184 ms 28372 KB
01_rnd_16.txt 190 ms 24908 KB
01_rnd_17.txt 190 ms 26964 KB
01_rnd_18.txt 185 ms 24652 KB
01_rnd_19.txt 185 ms 26580 KB