結果

問題 No.165 四角で囲え!
ユーザー ki_ki33ki_ki33
提出日時 2015-03-13 00:49:00
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 1,795 bytes
コンパイル時間 2,194 ms
コンパイル使用メモリ 79,444 KB
実行使用メモリ 68,952 KB
最終ジャッジ日時 2023-09-11 08:12:53
合計ジャッジ時間 14,778 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListSet;

public class Main {
	public static final int C =  1000000007;
	static final int CY = 1000000000;
	//static boolean MAP[][];
	static int N;
	static int B;
	static int[][] POS;
	static String S;
	static int K;
	static int X[][];
	//static String S[];
	static int HA[];

	static long DP[];
	static int ST[][];
	static ConcurrentSkipListSet<Integer> TS;
	static ArrayList<Integer> AL;
	public static void main(String[] args) {
		StringBuilder sb = new StringBuilder();
		BufferedInputStream bs = new BufferedInputStream(System.in);
		Scanner sc = new Scanner(bs);

		N = sc.nextInt();
		B = sc.nextInt();

		HashSet<Integer> X = new HashSet<Integer>();
		HashSet<Integer> Y = new HashSet<Integer>();

		POS = new int[N][3];
		for (int i=0; i < N; i++) {
			POS[i][0] = sc.nextInt()*2;
			POS[i][1] = sc.nextInt()*2;
			POS[i][2] = sc.nextInt();
			X.add(POS[i][0]);
			Y.add(POS[i][1]);
		}

		long ans = 1;

		for (int x1 :X) {
			for (int x2: X) {
				for(int y1: Y) {
					LOOP:for (int y2:Y) {


						int x = Math.min(x1, x2) - 1;
						int y = Math.min(y1, y2) - 1;
						Rectangle rect = new Rectangle(x, y,Math.abs(x1 - x2) + 2, Math.abs(y1 - y2)+ 2);
						int num = 0;
						int b = 0;
						for (int t=0; t < N; t++) {
							if (rect.contains(new Point(POS[t][0], POS[t][1]))) {
								num++;
								b += POS[t][2];
								if (b > B) {
									continue LOOP;
								}
							}
						}
						ans = Math.max(ans, num);
					}
				}
			}
		}





		System.out.println(ans);
	}
}
0