結果

問題 No.165 四角で囲え!
ユーザー sugim48sugim48
提出日時 2015-03-12 23:54:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2,106 ms / 5,000 ms
コード長 1,825 bytes
コンパイル時間 1,096 ms
コンパイル使用メモリ 103,680 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-26 23:32:41
合計ジャッジ時間 26,252 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 998 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1,297 ms
4,380 KB
testcase_06 AC 226 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 863 ms
4,380 KB
testcase_12 AC 1,124 ms
4,380 KB
testcase_13 AC 1,245 ms
4,380 KB
testcase_14 AC 1,269 ms
4,380 KB
testcase_15 AC 1,349 ms
4,380 KB
testcase_16 AC 2,101 ms
4,380 KB
testcase_17 AC 2,067 ms
4,384 KB
testcase_18 AC 2,075 ms
4,384 KB
testcase_19 AC 2,106 ms
4,380 KB
testcase_20 AC 2,077 ms
4,388 KB
testcase_21 AC 2,082 ms
4,380 KB
testcase_22 AC 2,092 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <complex>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int v, w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	int N, B; cin >> N >> B;
	vector<pair<i_i, int> > a(N);
	for (int i = 0; i < N; i++) {
		int X, Y, P; cin >> X >> Y >> P;
		a[i] = make_pair(i_i(X, Y), P);
	}
	a.push_back(make_pair(i_i(1111111111, 0), 0));
	sort(a.begin(), a.end());
	int maxi = 0;
	for (int l = 0; l <= N; l++)
		for (int r = l; r <= N; r++) {
			map<int, int> m1, m2;
			for (int i = 0; i < N; i++) {
				int x = a[i].first.first;
				int y = a[i].first.second;
				int p = a[i].second;
				if (x >= a[l].first.first && x < a[r].first.first) {
					m1[y]++;
					m2[y] += p;
				}
			}
			vector<int> unko1, unko2;
			for (auto it = m1.begin(); it != m1.end(); it++)
				unko1.push_back(it->second);
			for (auto it = m2.begin(); it != m2.end(); it++)
				unko2.push_back(it->second);
			int n = unko1.size();
			vector<int> unko3(n + 1), unko4(n + 1);
			for (int i = 1; i <= n; i++) {
				unko3[i] = unko3[i - 1] + unko1[i - 1];
				unko4[i] = unko4[i - 1] + unko2[i - 1];
			}
			int d = 0, sum = 0;
			for (int u = 0; u <= n; u++) {
				while (d + 1 <= n && unko4[d + 1] - unko4[u] <= B) d++;
				maxi = max(maxi, unko3[d] - unko3[u]);
			}
		}
	cout << maxi << endl;
}
0