結果
| 問題 |
No.165 四角で囲え!
|
| ユーザー |
omu
|
| 提出日時 | 2015-03-18 00:02:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,224 bytes |
| コンパイル時間 | 662 ms |
| コンパイル使用メモリ | 73,316 KB |
| 実行使用メモリ | 9,472 KB |
| 最終ジャッジ日時 | 2024-06-28 23:09:03 |
| 合計ジャッジ時間 | 19,657 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 12 TLE * 1 -- * 6 |
ソースコード
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
#define clr(t) memset(t,0,sizeof(t))
#define rep(i,n) for(int (i) = 0;i < (n);i++)
using namespace std;
int main()
{
int n,b;
cin >> n >> b;
map<int,int> mx,my;
int x[500],y[500],p[500];
rep(i, n){
cin >> x[i] >> y[i] >> p[i];
mx[x[i]] = my[y[i]] = 0;
}
int xcount = 0;
for (auto && i : mx)
i.second = xcount++;
int ycount = 0;
for (auto && i : my)
i.second = ycount++;
int d[500][500]; clr(d);
rep(i, n)
{
d[mx[x[i]]][my[y[i]]] = p[i];
}
int ans = 0;
rep(x1,xcount)
for (int x2 = x1; x2 < xcount; x2++)
{
int y1=0,y2=0;
int psum = 0;int sum = 0;
for (int x = x1; x < x2 + 1; x++){
psum += d[x][0];
sum += d[x][0]?1:0;
}
if (psum <= b)
ans = max(sum, ans);
while (!(y1 == ycount-1 && y2 == ycount-1))
{
if (psum > b || y2 == ycount-1)
{
for (int x = x1; x < x2 + 1; x++){
psum -= d[x][y1];
sum -= d[x][y1] ? 1 : 0;
}
y1++;
}
else
{
y2++;
for (int x = x1; x < x2 + 1; x++){
psum += d[x][y2];
sum += d[x][y2] ? 1 : 0;
}
}
if (psum <= b)
ans = max(sum,ans);
}
}
cout << ans << endl;
return 0;
}
omu