Submission #2694660


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 = sc.nextInt();
        int[][] array = new int[n][2];

        for(int i=0; i<n; i++){
            for(int j=0; j<2; j++){
                array[i][j] = sc.nextInt();
            }
        }

        double maxVal = 0;

        for(int i=0; i<n-1; i++){
            int x = array[i][0];
            int y = array[i][1];

            for(int j=i+1; j<n; j++){
                int targetX = array[j][0];
                int targetY = array[j][1];

                maxVal = Math.max(maxVal, distance(x, y, targetX, targetY));
            }
        }

        System.out.println(maxVal);
    }

    static double distance(int x, int y, int targetX, int targetY){
        return Math.sqrt(Math.pow(targetX - x, 2) + Math.pow(targetY - y, 2));
    }
}

Submission Info

Submission Time
Task A - 2点間距離の最大値 ( The longest distance )
User tottiiiiiii
Language Java8 (OpenJDK 1.8.0)
Score 100
Code Size 932 Byte
Status
Exec Time 107 ms
Memory 23892 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 94 ms 19284 KB
00_sample_01.txt 94 ms 19284 KB
00_sample_02.txt 93 ms 21076 KB
00_sample_03.txt 94 ms 17492 KB
00_sample_04.txt 93 ms 21844 KB
00_sample_05.txt 93 ms 19796 KB
01_rnd_00.txt 102 ms 21844 KB
01_rnd_01.txt 102 ms 18772 KB
01_rnd_02.txt 105 ms 21204 KB
01_rnd_03.txt 104 ms 21204 KB
01_rnd_04.txt 104 ms 21972 KB
01_rnd_05.txt 105 ms 19284 KB
01_rnd_06.txt 103 ms 21588 KB
01_rnd_07.txt 105 ms 23124 KB
01_rnd_08.txt 104 ms 19284 KB
01_rnd_09.txt 102 ms 18772 KB
01_rnd_10.txt 104 ms 17104 KB
01_rnd_11.txt 103 ms 21204 KB
01_rnd_12.txt 103 ms 22100 KB
01_rnd_13.txt 104 ms 21332 KB
01_rnd_14.txt 103 ms 18772 KB
01_rnd_15.txt 104 ms 19668 KB
01_rnd_16.txt 103 ms 23892 KB
01_rnd_17.txt 107 ms 19668 KB
01_rnd_18.txt 105 ms 18640 KB
01_rnd_19.txt 105 ms 21332 KB