結果

問題 No.165 四角で囲え!
ユーザー masamasa
提出日時 2015-09-23 20:16:38
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 890 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 67,108 KB
実行使用メモリ 7,652 KB
最終ジャッジ日時 2023-09-26 14:39:23
合計ジャッジ時間 13,770 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main() {
	int n, b;

	cin >> n >> b;
	vector<int> x(n, 0), y(n, 0), p(n, 0);

	int ans = 0;

	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> p[i];

		if (p[i] < b) {
			ans = 1;
		}
	}

	if (ans == 0) {
		cout << ans << endl;
		return 0;
	}

	auto xx = x;
	auto yy = y;
	sort(xx.begin(), xx.end());
	sort(yy.begin(), yy.end());

	int total;
	int n_point;
	for (int i = 0; i < n; i++) {
	for (int j = i + 1; j < n; j++) {
	for (int k = 0; k < n; k++) {
	for (int l = k + 1; l < n; l++) {
		total = 0;
		n_point = 0;
		for (int m = 0; m < n; m++) {
			if (xx[i] <= x[m] && x[m] <= xx[j] && yy[k] <= y[m] && y[m] <= yy[l]) {
				total += p[m];
				n_point++;
			}
		}
		if (total <= b) {
			ans = max(ans, n_point);
		}
	}}}}

	cout << ans << endl;
	return 0;
}
0