結果
| 問題 |
No.165 四角で囲え!
|
| コンテスト | |
| ユーザー |
moti
|
| 提出日時 | 2015-04-15 03:17:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 182 ms / 5,000 ms |
| コード長 | 1,128 bytes |
| コンパイル時間 | 1,113 ms |
| コンパイル使用メモリ | 78,404 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-26 03:29:43 |
| 合計ジャッジ時間 | 3,463 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
int N; ll B;
map<int, int> MX, MY;
int X[500], Y[500], P[500];
vector<pair<int, int>> D[500];
int ma = 0;
int main()
{
cin >> N >> B;
rep(i, N) cin >> X[i] >> Y[i] >> P[i], MX[X[i]] = MY[Y[i]] = 0;
int INF = 1e9+1;
MX[-INF] = MY[-INF] = 0;
MX[INF] = MY[INF] = 0;
int x1 = 0, y1 = 0;
for(auto& e: MX) e.second = x1++;
for(auto& e: MY) e.second = y1++;
rep(i, N) D[MY[Y[i]]].emplace_back(MX[X[i]], P[i]);
rep(x1, MX.size()) REP(x2, x1, MX.size()) {
int num = 0;
ll tot = 0;
y1 = 0;
rep(y2, MY.size()) {
for(auto& e: D[y2]) {
if(e.first >= x1 && e.first <= x2) {
num ++, tot += e.second;
}
}
while(tot > B) {
for(auto& e: D[y1]) {
if(e.first >= x1 && e.first <= x2) {
num --;
tot -= e.second;
}
}
y1++;
}
ma = max(ma, num);
}
}
cout << ma << endl;
return 0;
}
moti