結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー KKT89KKT89
提出日時 2019-06-17 20:25:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 985 bytes
コンパイル時間 1,196 ms
コンパイル使用メモリ 83,400 KB
実行使用メモリ 12,848 KB
最終ジャッジ日時 2023-08-19 02:32:26
合計ジャッジ時間 4,541 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 81 ms
12,552 KB
testcase_15 WA -
testcase_16 AC 79 ms
12,440 KB
testcase_17 WA -
testcase_18 AC 80 ms
12,528 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include <string>
#include <math.h>
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];
typedef long long int ll;
using namespace std;

const int MOD = 1000000007;
int cnt[6];
vector<int> a1[100010],b1[100010];
int main(){
  int n,m; cin >>n>>m;
  int ans=1e9;
  vector<int> x(n),a(n),b(n);
  for(int i=0;i<n;i++){
    cin >>x[i] >> a[i] >> b[i];
    a1[a[i]].push_back(i);
    b1[b[i]].push_back(i);
  }
  for(int i=0;i<n;i++){
    x[i]++;
    cnt[x[i]]++;
  }
  int B=0;
  for(int A=100001;A>=0;A--){
    while(cnt[2]+cnt[3]+cnt[4]+cnt[5]>m){
      B++;
      if(B>100001)break;
      for(auto i:b1[B-1]){
        cnt[x[i]]--;
        x[i]--;
        cnt[x[i]]++;
      }
    }
    if(cnt[2]+cnt[3]+cnt[4]+cnt[5]>m)break;
    ans=min(ans,cnt[3]+cnt[4]+cnt[5]);
    if(A>0)for(auto i:a1[A-1]){
      cnt[x[i]]--;
      x[i]++;
      cnt[x[i]]++;
    }
  }
  cout << ans << endl;
}
0