結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー Tttt YayTttt Yay
提出日時 2021-03-31 20:27:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,696 bytes
コンパイル時間 5,524 ms
コンパイル使用メモリ 262,664 KB
実行使用メモリ 5,156 KB
最終ジャッジ日時 2023-08-21 18:12:20
合計ジャッジ時間 9,131 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
5,156 KB
testcase_01 AC 88 ms
5,004 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 3 ms
4,376 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 86 ms
4,956 KB
testcase_13 AC 88 ms
4,916 KB
testcase_14 AC 86 ms
4,896 KB
testcase_15 WA -
testcase_16 AC 84 ms
5,056 KB
testcase_17 AC 83 ms
4,960 KB
testcase_18 AC 83 ms
5,056 KB
testcase_19 AC 87 ms
4,888 KB
testcase_20 AC 84 ms
4,892 KB
testcase_21 AC 83 ms
4,984 KB
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,384 KB
testcase_25 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) x.begin(),x.end() 
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define V vector
#define P pair<int,int>
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using ll = long long;
using ld = long double;
using namespace std;
const int INF =1001001001;
const int INFL =1<<30;
const int MAX = 2e6+1;
const int xx=2555;






template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
const int MOD = 1000000007;
//const int MOD = 998244353;
using mint = Fp<MOD>;


int main() {
    int n,m;cin>>n>>m;
    V<P> a(n),b(n);
    V<int> x(n);
    rep(i,n){
        int x1,a1,b1;
        cin>>x1>>a1>>b1;
        x[i]=x1+1;
        a[i]=MP(a1,i);
        b[i]=MP(b1,i);
    }
    sort(all(a));
    sort(all(b));
    int anow=0,bnow=n-1;
    int kan2=0,kan3=0;
    rep(i,n){
        if(x[i]>=2)kan2++;
        if(x[i]>=3)kan3++;
    }
    int ans=INF;
    rep(sa,100001){
        while(anow<n&&a[anow].first<sa){
            x[a[anow].second]--;
            if(x[a[anow].second]==1)kan2--;
            if(x[a[anow].second]==2)kan3--;
            anow++;
        }
        while(bnow>=0&&kan2<m){
            int t=b[bnow].first;
            while(b[bnow].first==t){
                x[b[bnow].second]++;
                if(x[b[bnow].second]==2)kan2++;
                if(x[b[bnow].second]==3)kan3++;
                bnow--;
            }
        }
        chmin(ans,kan3);
    }
    cout<<ans<<endl;
    return 0;
}
0