結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー koprickykopricky
提出日時 2017-09-10 06:19:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 67 ms / 1,000 ms
コード長 2,038 bytes
コンパイル時間 1,264 ms
コンパイル使用メモリ 147,996 KB
実行使用メモリ 13,216 KB
最終ジャッジ日時 2023-08-20 09:48:47
合計ジャッジ時間 3,558 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
13,216 KB
testcase_01 AC 67 ms
13,040 KB
testcase_02 AC 6 ms
8,120 KB
testcase_03 AC 6 ms
8,288 KB
testcase_04 AC 6 ms
8,232 KB
testcase_05 AC 5 ms
8,140 KB
testcase_06 AC 5 ms
8,028 KB
testcase_07 AC 5 ms
8,348 KB
testcase_08 AC 6 ms
8,340 KB
testcase_09 AC 5 ms
8,116 KB
testcase_10 AC 6 ms
8,112 KB
testcase_11 AC 6 ms
8,232 KB
testcase_12 AC 66 ms
12,428 KB
testcase_13 AC 67 ms
12,780 KB
testcase_14 AC 66 ms
12,644 KB
testcase_15 AC 64 ms
12,440 KB
testcase_16 AC 61 ms
12,476 KB
testcase_17 AC 59 ms
12,476 KB
testcase_18 AC 63 ms
12,404 KB
testcase_19 AC 66 ms
12,400 KB
testcase_20 AC 64 ms
12,520 KB
testcase_21 AC 62 ms
12,540 KB
testcase_22 AC 65 ms
12,908 KB
testcase_23 AC 6 ms
8,060 KB
testcase_24 AC 5 ms
8,100 KB
testcase_25 AC 6 ms
8,100 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