結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー koprickykopricky
提出日時 2017-09-10 06:19:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 57 ms / 1,000 ms
コード長 2,038 bytes
コンパイル時間 1,333 ms
コンパイル使用メモリ 161,676 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-05-07 16:51:11
合計ジャッジ時間 3,517 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
13,056 KB
testcase_01 AC 50 ms
12,864 KB
testcase_02 AC 5 ms
8,064 KB
testcase_03 AC 5 ms
8,192 KB
testcase_04 AC 5 ms
8,064 KB
testcase_05 AC 5 ms
8,064 KB
testcase_06 AC 5 ms
8,064 KB
testcase_07 AC 5 ms
8,064 KB
testcase_08 AC 5 ms
8,064 KB
testcase_09 AC 5 ms
8,064 KB
testcase_10 AC 4 ms
8,064 KB
testcase_11 AC 5 ms
8,064 KB
testcase_12 AC 49 ms
12,672 KB
testcase_13 AC 54 ms
12,672 KB
testcase_14 AC 51 ms
12,744 KB
testcase_15 AC 52 ms
12,608 KB
testcase_16 AC 50 ms
12,612 KB
testcase_17 AC 49 ms
12,672 KB
testcase_18 AC 53 ms
12,544 KB
testcase_19 AC 54 ms
12,612 KB
testcase_20 AC 52 ms
12,616 KB
testcase_21 AC 51 ms
12,608 KB
testcase_22 AC 57 ms
12,928 KB
testcase_23 AC 5 ms
8,064 KB
testcase_24 AC 5 ms
8,064 KB
testcase_25 AC 5 ms
7,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;

vector<int> sa[MAX_N],sb[MAX_N];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    vector<int> x(n),a(n),b(n);
    rep(i,n){
        cin >> x[i] >> a[i] >> b[i];
        x[i]++;
        sa[a[i]].pb(i),sb[b[i]].pb(i);
    }
    int na = 0,nb = 100001;
    int two=0,three=0;
    rep(i,n){
        if(x[i] >= 2){
            two++;
            if(x[i] >= 3){
                three++;
            }
        }
    }
    int ans = INF;
    while(1){
        if(two >= m){
            ans = min(ans,three);
            na++;
            if(na > 100001){
                break;
            }
            rep(i,sa[na-1].size()){
                x[sa[na-1][i]]--;
                if(x[sa[na-1][i]] == 1){
                    two--;
                }else if(x[sa[na-1][i]] == 2){
                    three--;
                }
            }
        }else{
            nb--;
            if(nb < 0){
                break;
            }
            rep(i,sb[nb].size()){
                x[sb[nb][i]]++;
                if(x[sb[nb][i]] == 2){
                    two++;
                }else if(x[sb[nb][i]] == 3){
                    three++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0