結果

問題 No.165 四角で囲え!
ユーザー masa
提出日時 2015-09-23 20:16:38
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 890 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 65,684 KB
実行使用メモリ 9,884 KB
最終ジャッジ日時 2024-07-19 08:50:43
合計ジャッジ時間 13,125 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other TLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

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