結果

問題 No.165 四角で囲え!
ユーザー koyoprokoyopro
提出日時 2015-10-22 22:56:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,712 bytes
コンパイル時間 1,596 ms
コンパイル使用メモリ 153,276 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 05:03:32
合計ジャッジ時間 5,129 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 AC 103 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 189 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 138 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 140 ms
4,376 KB
testcase_21 AC 136 ms
4,376 KB
testcase_22 AC 132 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define int long long
#define REP(i, n) for(int i=0; i<(n); 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 comp(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> ys;
    REP(i,N) ys.push_back(i);
    sort(ALL(ys), comp);
    int maxn = 0;
    REP(i,N) REP(j,i) {
        int x0 = min(ps[i].x, ps[j].x);
        int x1 = max(ps[i].x, ps[j].x);
        int bottom = 0;
        int top = -1;
        int point = 0;
        int num = 0;
        // 尺取り法
        while(top < N) {
            if (top == -1) {
                P p = ps[ys[bottom]];
                if (p.x < x0 || x1 < p.x) {
                    bottom++;
                    continue;
                }
                top = bottom;
            }
            P p = ps[ys[top]];
            if (p.x < x0 || x1 < p.x) {
                top++;
                continue;
            }
            num++;
            point += p.p;
            while(top + 1 < N && ps[ys[top+1]].y == ps[ys[top]].y) {
                top++;
                P p = ps[ys[top]];
                if (p.x < x0 || x1 < p.x) {
                    continue;
                }
                point += p.p;
                num++;
            }
            while (point > B) {
                point -= ps[ys[bottom]].p;
                num--;
                bottom++;
            }
            maxn = max(maxn, num);
            // 次へ
            top++;
        }
    }
    cout << maxn << endl;
    return 0;
}
0