結果

問題 No.245 貫け!
ユーザー ぴろずぴろず
提出日時 2015-07-17 22:52:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,975 bytes
コンパイル時間 2,346 ms
コンパイル使用メモリ 78,896 KB
実行使用メモリ 68,100 KB
最終ジャッジ日時 2023-09-22 17:59:47
合計ジャッジ時間 18,930 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 201 ms
59,044 KB
testcase_01 AC 223 ms
58,992 KB
testcase_02 AC 223 ms
59,596 KB
testcase_03 AC 203 ms
59,108 KB
testcase_04 AC 230 ms
59,248 KB
testcase_05 AC 255 ms
61,948 KB
testcase_06 AC 277 ms
61,352 KB
testcase_07 AC 191 ms
58,784 KB
testcase_08 AC 478 ms
64,176 KB
testcase_09 WA -
testcase_10 AC 802 ms
65,876 KB
testcase_11 WA -
testcase_12 AC 1,439 ms
68,100 KB
testcase_13 AC 1,290 ms
62,360 KB
testcase_14 AC 1,224 ms
61,052 KB
testcase_15 WA -
testcase_16 AC 1,245 ms
63,776 KB
testcase_17 WA -
testcase_18 AC 1,292 ms
63,644 KB
testcase_19 AC 1,379 ms
63,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no245;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Vector2[][] seg = new Vector2[n][2];
		for(int i=0;i<n;i++) {
			seg[i][0] = new Vector2(sc.nextLong(), sc.nextLong());
			seg[i][1] = new Vector2(sc.nextLong(), sc.nextLong());
		}
		int ans = 0;
		for(int i=0;i<=200;i++) {
			for(int j=0;j<=200;j++) {
				if (i == 0 && j == 0) {
					continue;
				}
				Vector2 d = new Vector2(i, j);
				ArrayList<Event> al = new ArrayList<>();
				for(int k=0;k<n;k++) {
					long x1 = seg[k][0].dot(d);
					long x2 = seg[k][1].dot(d);
					al.add(new Event(Math.min(x1, x2), 1));
					al.add(new Event(Math.max(x1, x2), -1));
				}
				Collections.sort(al);
				int sum = 0;
				for(Event e:al) {
					sum += e.a;
					ans = Math.max(ans, sum);
				}
			}
		}
		System.out.println(ans);
	}

}
class Event implements Comparable<Event>{
	long x,a;
	public Event(long x,long a) {
		this.x = x;
		this.a = a;
	}
	public int compareTo(Event o) {
		if (x != o.x) {
			return Long.compare(x, o.x);
		}
		return - Long.compare(a, o.a);
	}
	public String toString() {
		return "[" + x + "," + a + "]";
	}
}
class Vector2 {
	long x = 0;
	long y = 0;
	public Vector2(long x,long y) {
		this.x = x;
		this.y = y;
	}
	public long dot(Vector2 v) {
		return this.x*v.x+this.y*v.y;
	}
	public long cross(Vector2 v) {
		return this.x*v.y-this.y*v.x;
	}
	public Vector2 add(Vector2 v) {
		return new Vector2(this.x+v.x,this.y+v.y);
	}
	public Vector2 subtract(Vector2 v) {
		return new Vector2(this.x-v.x,this.y-v.y);
	}
	public Vector2 multiply(long k) {
		return new Vector2(k*this.x,k*this.y);
	}
	public String toString() {
		return this.x + " " + this.y;
	}
	public boolean equals(Object o) {
		if (o instanceof Vector2) {
			Vector2 v = (Vector2) o;
			return x == v.x && y == v.y;
		}
		return super.equals(o);
	}
}
0