結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー KKT89KKT89
提出日時 2019-06-17 20:33:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 1,000 ms
コード長 973 bytes
コンパイル時間 747 ms
コンパイル使用メモリ 83,708 KB
実行使用メモリ 12,844 KB
最終ジャッジ日時 2023-08-19 03:01:28
合計ジャッジ時間 4,106 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
12,720 KB
testcase_01 AC 110 ms
12,844 KB
testcase_02 AC 5 ms
8,056 KB
testcase_03 AC 6 ms
8,176 KB
testcase_04 AC 6 ms
8,084 KB
testcase_05 AC 5 ms
8,112 KB
testcase_06 AC 6 ms
8,064 KB
testcase_07 AC 5 ms
8,112 KB
testcase_08 AC 5 ms
8,108 KB
testcase_09 AC 5 ms
8,044 KB
testcase_10 AC 5 ms
8,036 KB
testcase_11 AC 5 ms
8,232 KB
testcase_12 AC 106 ms
12,756 KB
testcase_13 AC 108 ms
12,720 KB
testcase_14 AC 106 ms
12,460 KB
testcase_15 AC 107 ms
12,412 KB
testcase_16 AC 101 ms
12,528 KB
testcase_17 AC 100 ms
12,568 KB
testcase_18 AC 100 ms
12,508 KB
testcase_19 AC 106 ms
12,456 KB
testcase_20 AC 101 ms
12,452 KB
testcase_21 AC 100 ms
12,496 KB
testcase_22 AC 107 ms
12,720 KB
testcase_23 AC 5 ms
8,124 KB
testcase_24 AC 5 ms
8,108 KB
testcase_25 AC 5 ms
8,052 KB
権限があれば一括ダウンロードができます

ソースコード

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=100001;
  for(int A=0;A<100002;A++){
    while(cnt[2]+cnt[3]+cnt[4]+cnt[5]<m){
      B--;
      if(B<0)break;
      for(auto i:b1[B]){
        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]);
    for(auto i:a1[A]){
      cnt[x[i]]--;
      x[i]--;
      cnt[x[i]]++;
    }
  }
  cout << ans << endl;
}
0