結果
問題 | No.2790 Athena 3 |
ユーザー |
![]() |
提出日時 | 2024-06-24 10:45:11 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 64 ms / 2,000 ms |
コード長 | 2,470 bytes |
コンパイル時間 | 4,601 ms |
コンパイル使用メモリ | 78,680 KB |
実行使用メモリ | 37,276 KB |
最終ジャッジ日時 | 2024-06-24 10:45:18 |
合計ジャッジ時間 | 4,806 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
import java.io.*;import java.util.*;import java.util.function.*;import java.util.stream.*;public class Main {public static void main(String[] args) throws Exception {Scanner sc = new Scanner();Point[] points = new Point[3];for (int i = 0; i < 3; i++) {points[i] = new Point(sc.nextInt(), sc.nextInt());}Point[] pattern = new Point[]{new Point(1, 0), new Point(-1, 0), new Point(0, 1), new Point(0, -1)};double ans = 0;for (int i = 0; i < 4; i++) {points[0].add(pattern[i]);for (int j = 0; j < 4; j++) {points[1].add(pattern[j]);for (int k = 0; k < 4; k++) {points[2].add(pattern[k]);ans = Math.max(ans, points[0].getSpace(points[1], points[2]));points[2].draw(pattern[k]);}points[1].draw(pattern[j]);}points[0].draw(pattern[i]);}System.out.println(ans);}static class Point {double x;double y;public Point(double x, double y) {this.x = x;this.y = y;}public void add(Point p) {x += p.x;y += p.y;}public void draw(Point p) {x -= p.x;y -= p.y;}public double getSpace(Point p1, Point p2) {double ans = (p1.x - x) * (p2.y - y) - (p1.y - y) * (p2.x - x);return Math.abs(ans) / 2;}}}class Scanner {BufferedReader br;StringTokenizer st = new StringTokenizer("");StringBuilder sb = new StringBuilder();public Scanner() {try {br = new BufferedReader(new InputStreamReader(System.in));} catch (Exception e) {}}public int nextInt() {return Integer.parseInt(next());}public long nextLong() {return Long.parseLong(next());}public double nextDouble() {return Double.parseDouble(next());}public String next() {try {while (!st.hasMoreTokens()) {st = new StringTokenizer(br.readLine());}} catch (Exception e) {e.printStackTrace();} finally {return st.nextToken();}}}