結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー parukiparuki
提出日時 2017-09-11 08:34:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,135 bytes
コンパイル時間 1,595 ms
コンパイル使用メモリ 167,592 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-25 06:40:16
合計ジャッジ時間 5,851 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 64 ms
7,552 KB
testcase_03 AC 63 ms
7,680 KB
testcase_04 AC 57 ms
7,680 KB
testcase_05 AC 67 ms
7,552 KB
testcase_06 AC 59 ms
7,552 KB
testcase_07 AC 61 ms
7,680 KB
testcase_08 AC 8 ms
7,552 KB
testcase_09 AC 67 ms
7,424 KB
testcase_10 AC 68 ms
7,680 KB
testcase_11 AC 63 ms
7,680 KB
testcase_12 AC 124 ms
10,496 KB
testcase_13 AC 124 ms
10,624 KB
testcase_14 AC 129 ms
10,496 KB
testcase_15 AC 120 ms
10,624 KB
testcase_16 AC 125 ms
10,496 KB
testcase_17 AC 123 ms
10,368 KB
testcase_18 AC 120 ms
10,496 KB
testcase_19 AC 127 ms
10,496 KB
testcase_20 AC 129 ms
10,624 KB
testcase_21 AC 124 ms
10,496 KB
testcase_22 WA -
testcase_23 AC 59 ms
7,552 KB
testcase_24 AC 69 ms
7,552 KB
testcase_25 AC 67 ms
7,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define rt return
using dbl = double;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class Val>
struct BinaryIndexedTree {
    int n;
    vector<Val> t;
    BinaryIndexedTree() {}
    BinaryIndexedTree(int _n) :n(_n + 1), t(_n + 1) {}
    void add(int k, Val val) {
        k++;
        while (k < n) {
            t[k] += val;
            k += (k&-k);
        }
    }
    void set(int k, Val val) {
        add(k, -sum(k, k + 1));
        add(k, val);
    }
    Val sum(int k) {
        Val r = 0;
        while (k > 0) {
            r += t[k];
            k -= (k&-k);
        }
        return r;
    }
    Val sum(int l, int r) {
        return sum(r) - sum(l);
    }
};

const int R = 100001;
BinaryIndexedTree<int> sum[5];
vi aid[R];

int f(int b, int mi) {
    int res = 0;
    rep(i, 5) {
        if (i >= mi)res += sum[i].sum(0, R);
        else if (i + 1 >= mi)res += sum[i].sum(b, R);
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    rep(i, 5)sum[i] = BinaryIndexedTree<int>(R);

    int N, M;
    cin >> N >> M;

    vi X(N), A(N), B(N);
    rep(i, N) {
        cin >> X[i] >> A[i] >> B[i];
        aid[A[i]].push_back(i);
        sum[X[i]].add(B[i], 1);
    }

    int ans = INT_MAX;
    for (int a = R - 1; a >= 0; --a) {
        each(i, aid[a]) {
            sum[X[i]].add(B[i], -1);
            sum[X[i] + 1].add(B[i], 1);
        }

        if (f(0, 2) < M)continue;
        int ok = 0, ng = R, mid;
        while (ng - ok > 1) {
            mid = (ok + ng) / 2;
            (f(mid, 2) >= M ? ok : ng) = mid;
        }

        smin(ans, f(ok, 3));
    }

    cout << ans << endl;
}
0