結果

問題 No.165 四角で囲え!
ユーザー face4face4
提出日時 2019-09-28 10:37:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,452 bytes
コンパイル時間 946 ms
コンパイル使用メモリ 88,800 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-09 03:29:49
合計ジャッジ時間 45,229 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,683 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,948 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2,107 ms
6,944 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,948 KB
testcase_08 AC 2 ms
6,948 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3,350 ms
6,944 KB
testcase_13 AC 3,376 ms
6,944 KB
testcase_14 AC 2,550 ms
6,944 KB
testcase_15 AC 2,611 ms
6,944 KB
testcase_16 AC 3,325 ms
6,944 KB
testcase_17 AC 3,285 ms
6,948 KB
testcase_18 WA -
testcase_19 AC 3,295 ms
6,944 KB
testcase_20 AC 3,290 ms
6,944 KB
testcase_21 AC 3,309 ms
6,944 KB
testcase_22 AC 3,287 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;

#define inRange(x,a,b) (a <= x && x <= b)
typedef pair<int,int> pii;

int main(){
    int n, b;
    cin >> n >> b;
    vector<pair<pii,int>> vp;
    for(int i = 0; i < n; i++){
        int x, y, p;
        cin >> x >> y >> p;
        vp.push_back({{x,y},p});
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int low = vp[i].first.second, high = vp[j].first.second;
            if(low > high)  swap(low, high);
            map<int,int> ms, mv;
            for(int k = 0; k < n; k++){
                if(inRange(vp[k].first.second, low, high)){
                    ms[vp[k].first.first] += (vp[k].second);
                    mv[vp[k].first.first]++;
                }
            }
            vector<int> vs, vv;
            for(auto p : ms)    vs.push_back(p.second);
            for(auto p : mv)    vv.push_back(p.second);
            int l = 0, r = 0, sum = 0, cnt = 0;
            while(l < vs.size()){
                while(r < vs.size() && sum+vs[r] <= b){
                    sum += vs[r];
                    cnt += vv[r];
                    r++;
                }
                ans = max(ans, cnt);
                sum -= vs[l];
                cnt -= vv[l];
                l++;
                if(vs[r] > b)    l = ++r;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0