結果
| 問題 | No.165 四角で囲え! |
| コンテスト | |
| ユーザー |
maine_honzuki
|
| 提出日時 | 2020-06-02 23:59:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 382 ms / 5,000 ms |
| コード長 | 1,602 bytes |
| コンパイル時間 | 1,629 ms |
| コンパイル使用メモリ | 184,612 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-24 19:20:29 |
| 合計ジャッジ時間 | 5,901 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int N, B, X[500], Y[500], P[500];
cin >> N >> B;
for (int i = 0; i < N; i++) {
cin >> X[i] >> Y[i] >> P[i];
}
vector<int> V;
map<int, vector<pair<int, int>>> M;
for (int i = 0; i < N; i++) {
V.emplace_back(X[i]);
M[Y[i]].push_back({X[i], P[i]});
}
M[-1000000001] = {};
sort(V.begin(), V.end());
int ans = 0;
for (int i = 0; i < V.size(); i++) {
for (int j = i; j < V.size(); j++) {
auto y1 = M.begin();
auto y2 = M.begin();
int p = 0;
int cnt = 0;
while (y2 != M.end()) {
if (p < B || y1 == y2) {
y2++;
if (y2 == M.end())
break;
for (auto& t : (*y2).second) {
if (V[i] <= t.first && t.first <= V[j]) {
cnt++;
p += t.second;
}
}
if (p <= B)
ans = max(ans, cnt);
} else {
for (auto& t : (*y1).second) {
if (V[i] <= t.first && t.first <= V[j]) {
cnt--;
p -= t.second;
}
}
y1++;
if (p <= B)
ans = max(ans, cnt);
}
}
}
}
cout << ans << endl;
}
maine_honzuki