結果
| 問題 | No.165 四角で囲え! |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-03-15 03:56:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,481 bytes |
| 記録 | |
| コンパイル時間 | 835 ms |
| コンパイル使用メモリ | 81,544 KB |
| 実行使用メモリ | 8,704 KB |
| 最終ジャッジ日時 | 2024-06-28 22:54:44 |
| 合計ジャッジ時間 | 13,276 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | TLE * 1 -- * 18 |
ソースコード
#include <cstdint>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
using namespace std;
int N;
int B;
struct Point
{
Point() {}
Point(int x, int y, int p) : x(x), y(y), p(p) {}
int x;
int y;
int p;
};
vector<Point> points;
void input(istream& in)
{
in >> N >> B;
points.resize(N);
for (int i = 0; i < N; i++) {
in >> points[i].x >> points[i].y >> points[i].p;
}
}
int resolve()
{
map<int, vector<Point*>> Xmap;
map<int, vector<Point*>> Ymap;
for (int i = 0; i < N; i++) {
Xmap[points[i].x].push_back(&points[i]);
Ymap[points[i].y].push_back(&points[i]);
}
vector<int> X;
for (auto ite : Xmap) {
X.push_back(ite.first);
}
vector<int> Y;
for (auto ite : Ymap) {
Y.push_back(ite.first);
}
int best_count = 0;
for (size_t ix1 = 0; ix1 < X.size(); ix1++) {
int x1 = X[ix1];
for (size_t ix2 = ix1; ix2 < X.size(); ix2++) {
int x2 = X[ix2];
for (size_t iy1 = 0; iy1 < Y.size(); iy1++) {
int y1 = Y[iy1];
int count = 0;
int score = 0;
for (size_t iy2 = iy1; iy2 < Y.size(); iy2++) {
int y2 = Y[iy2];
for (auto ppoint : Ymap[y2]) {
if (x1 <= ppoint->x && ppoint->x <= x2) {
count++;
score += ppoint->p;
}
}
if (score > B) {
break;
}
if (count > best_count) {
best_count = count;
}
}
}
}
}
return best_count;
}
int main(int argc, char **argv)
{
input(cin);
cout << resolve() << endl;
return 0;
}