結果
| 問題 |
No.165 四角で囲え!
|
| コンテスト | |
| ユーザー |
koyopro
|
| 提出日時 | 2015-10-22 23:38:31 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,650 bytes |
| コンパイル時間 | 1,650 ms |
| コンパイル使用メモリ | 167,600 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-22 23:01:21 |
| 合計ジャッジ時間 | 11,435 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 WA * 3 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
struct P { int x, y, p; P(){}; P(int _x, int _y): x(_x), y(_y){}; };
int N,T,B;
vector<P> ps;
bool compx(int i, int j) {
return ps[i].x < ps[j].x;
}
bool compy(int i, int j) {
return ps[i].y < ps[j].y;
}
signed main()
{
cin >> N >> B;
ps.resize(N);
REP(i,N) cin >> ps[i].x >> ps[i].y >> ps[i].p;
vector<int> xs;
vector<int> ys;
REP(i,N) xs.push_back(i);
REP(i,N) ys.push_back(i);
sort(ALL(ys), compy);
sort(ALL(xs), compx);
int maxn = 0;
REP(i,N) REP(j,i+1) {
int bottom = 0;
int top = 0;
int point = 0;
int num = 0;
vector<int> qs;
FOR(k,j,i+1) {
qs.push_back(xs[k]);
}
sort(ALL(qs), compy);
// 尺取り法
while(top < qs.size()) {
P p = ps[qs[top]];
num++;
point += p.p;
while(top + 1 < qs.size() && ps[qs[top+1]].y == p.y) {
top++;
P p = ps[qs[top]];
point += p.p;
num++;
}
while (point > B) {
int y = ps[qs[bottom]].y;
while(bottom <= top && ps[qs[bottom]].y == y) {
point -= ps[qs[bottom]].p;
num--;
bottom++;
}
}
maxn = max(maxn, num);
// 次へ
top++;
}
}
cout << maxn << endl;
return 0;
}
koyopro