Submission #2177972
Source Code Expand
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; public class Main { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskX solver = new TaskX(); solver.solve(1, in, out); out.close(); } static class TaskX { public void solve(int testNumber, InputReader in, PrintWriter out) { int n = in.nextInt(); Point[] p = new Point[n]; for (int i = 0; i < n; i++) { int x = in.nextInt(); int y = in.nextInt(); p[i] = new Point(x, y); } double ans = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < p.length; j++) { ans = Math.max(ans, MathUtils.getDistance(p[i], p[j])); } } out.println(String.format("%.6f", ans)); } } static class ArrayUtils { public static Map<Integer, Integer> getCountMap(int[] array) { Map<Integer, Integer> map = new TreeMap<>(); for (int x : array) map.merge(x, 1, Integer::sum); return map; } } static class MathUtils { public static double getDistance(Point p1, Point p2) { double dist = 0; dist = Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2)); return dist; } } static class Point { int x; int y; Point(int x, int y) { this.x = x; this.y = y; } } static class InputReader { BufferedReader in; StringTokenizer tok; public String nextString() { while (!tok.hasMoreTokens()) { try { tok = new StringTokenizer(in.readLine(), " "); } catch (IOException e) { throw new InputMismatchException(); } } return tok.nextToken(); } public int nextInt() { return Integer.parseInt(nextString()); } public long nextLong() { return Long.parseLong(nextString()); } public int[] nextIntArray(int n) { int[] res = new int[n]; for (int i = 0; i < n; i++) { res[i] = nextInt(); } return res; } public long[] nextLongArray(int n) { long[] res = new long[n]; for (int i = 0; i < n; i++) { res[i] = nextLong(); } return res; } public InputReader(InputStream inputStream) { in = new BufferedReader(new InputStreamReader(inputStream)); tok = new StringTokenizer(""); } } }
Submission Info
Submission Time | |
---|---|
Task | A - 2点間距離の最大値 ( The longest distance ) |
User | tutuz |
Language | Java8 (OpenJDK 1.8.0) |
Score | 100 |
Code Size | 2689 Byte |
Status | AC |
Exec Time | 80 ms |
Memory | 23508 KB |
Judge Result
Set Name | All | ||
---|---|---|---|
Score / Max Score | 100 / 100 | ||
Status |
|
Set Name | Test Cases |
---|---|
All | 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 | AC | 76 ms | 20692 KB |
00_sample_01.txt | AC | 76 ms | 21460 KB |
00_sample_02.txt | AC | 76 ms | 22996 KB |
00_sample_03.txt | AC | 75 ms | 20564 KB |
00_sample_04.txt | AC | 75 ms | 19540 KB |
00_sample_05.txt | AC | 77 ms | 21076 KB |
01_rnd_00.txt | AC | 79 ms | 21460 KB |
01_rnd_01.txt | AC | 76 ms | 21076 KB |
01_rnd_02.txt | AC | 78 ms | 19156 KB |
01_rnd_03.txt | AC | 77 ms | 21460 KB |
01_rnd_04.txt | AC | 78 ms | 16340 KB |
01_rnd_05.txt | AC | 78 ms | 19540 KB |
01_rnd_06.txt | AC | 77 ms | 19540 KB |
01_rnd_07.txt | AC | 80 ms | 21332 KB |
01_rnd_08.txt | AC | 78 ms | 18772 KB |
01_rnd_09.txt | AC | 76 ms | 19540 KB |
01_rnd_10.txt | AC | 76 ms | 21588 KB |
01_rnd_11.txt | AC | 78 ms | 21076 KB |
01_rnd_12.txt | AC | 77 ms | 19540 KB |
01_rnd_13.txt | AC | 77 ms | 18004 KB |
01_rnd_14.txt | AC | 78 ms | 23508 KB |
01_rnd_15.txt | AC | 79 ms | 18644 KB |
01_rnd_16.txt | AC | 77 ms | 19540 KB |
01_rnd_17.txt | AC | 78 ms | 20820 KB |
01_rnd_18.txt | AC | 79 ms | 19284 KB |
01_rnd_19.txt | AC | 76 ms | 18004 KB |