結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー HyadoHyado
提出日時 2019-06-17 14:29:03
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,557 bytes
コンパイル時間 2,055 ms
コンパイル使用メモリ 172,176 KB
実行使用メモリ 7,116 KB
最終ジャッジ日時 2023-08-18 07:59:36
合計ジャッジ時間 6,261 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
7,100 KB
testcase_01 AC 93 ms
6,948 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,384 KB
testcase_08 RE -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 89 ms
6,676 KB
testcase_13 AC 91 ms
7,040 KB
testcase_14 AC 88 ms
6,836 KB
testcase_15 WA -
testcase_16 AC 86 ms
6,736 KB
testcase_17 AC 85 ms
6,652 KB
testcase_18 AC 87 ms
6,648 KB
testcase_19 AC 89 ms
6,724 KB
testcase_20 AC 87 ms
6,696 KB
testcase_21 AC 87 ms
6,832 KB
testcase_22 AC 91 ms
7,116 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);


signed main(){
    ll n,m,nk=0,sk=0,ans=INF;
    cin>>n>>m;
    ll cnt[n];//index i番目の完答数
    vector<pair<ll,ll>> f(n),s(n);

    for(int i=0;i < n;i++)
    {
        cin>>cnt[i];
        cnt[i]++;
        cin>>f.at(i).fi>>s.at(i).fi;
        f.at(i).se=i;
        s.at(i).se=i;
        if(cnt[i]>=3){
            sk++;
            nk++;
        }else if(cnt[i]>=2){
            nk++;
        }
    }
    sort(f.begin(),f.end());
    sort(s.begin(),s.end());

    ll l=0,r=n;
    if(nk>=m)ans=min(ans,sk);

    for(int l=0;l <= n;l++)
    {
        if(l>0){
            cnt[f.at(l-1).se]--;
            if(cnt[f.at(l-1).se]==2){
                sk--;
            }else if(cnt[f.at(l-1).se]==1){
                nk--;
            }

            if(l<n && f.at(l-1).fi==f.at(l).fi){
                continue;
            }
        }

        while(m>nk || (r<n-1 &&s.at(r).fi==s.at(r+1).fi)){
            if(r>-1) r--;
            else break;

            if(r<n-1){
                cnt[s.at(r+1).se]++;
                if(cnt[s.at(r+1).se]==3){
                    sk++;
                }else if(cnt[s.at(r+1).se]==2){
                    nk++;
                }
            }
        }
        //if(ans>sk)cout << l<<" "<<r << endl;
        ans=min(ans,sk);
    }
    
    cout << ans << endl;
}
0