AtCoder Regular Contest 004

Submission #2694660

Source codeソースコード

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

Task問題 A - 2点間距離の最大値 ( The longest distance )
User nameユーザ名 mittun
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 932 Byte
File nameファイル名
Exec time実行時間 107 ms
Memory usageメモリ使用量 23892 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 94 ms 19284 KB
00_sample_01.txt AC 94 ms 19284 KB
00_sample_02.txt AC 93 ms 21076 KB
00_sample_03.txt AC 94 ms 17492 KB
00_sample_04.txt AC 93 ms 21844 KB
00_sample_05.txt AC 93 ms 19796 KB
01_rnd_00.txt AC 102 ms 21844 KB
01_rnd_01.txt AC 102 ms 18772 KB
01_rnd_02.txt AC 105 ms 21204 KB
01_rnd_03.txt AC 104 ms 21204 KB
01_rnd_04.txt AC 104 ms 21972 KB
01_rnd_05.txt AC 105 ms 19284 KB
01_rnd_06.txt AC 103 ms 21588 KB
01_rnd_07.txt AC 105 ms 23124 KB
01_rnd_08.txt AC 104 ms 19284 KB
01_rnd_09.txt AC 102 ms 18772 KB
01_rnd_10.txt AC 104 ms 17104 KB
01_rnd_11.txt AC 103 ms 21204 KB
01_rnd_12.txt AC 103 ms 22100 KB
01_rnd_13.txt AC 104 ms 21332 KB
01_rnd_14.txt AC 103 ms 18772 KB
01_rnd_15.txt AC 104 ms 19668 KB
01_rnd_16.txt AC 103 ms 23892 KB
01_rnd_17.txt AC 107 ms 19668 KB
01_rnd_18.txt AC 105 ms 18640 KB
01_rnd_19.txt AC 105 ms 21332 KB