結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー KKT89KKT89
提出日時 2019-06-17 20:33:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 1,000 ms
コード長 973 bytes
コンパイル時間 787 ms
コンパイル使用メモリ 85,204 KB
実行使用メモリ 13,184 KB
最終ジャッジ日時 2024-05-06 10:11:41
合計ジャッジ時間 3,332 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
13,056 KB
testcase_01 AC 103 ms
13,056 KB
testcase_02 AC 5 ms
8,064 KB
testcase_03 AC 6 ms
8,192 KB
testcase_04 AC 5 ms
8,192 KB
testcase_05 AC 6 ms
8,064 KB
testcase_06 AC 6 ms
8,192 KB
testcase_07 AC 6 ms
8,192 KB
testcase_08 AC 5 ms
8,192 KB
testcase_09 AC 5 ms
8,192 KB
testcase_10 AC 5 ms
8,192 KB
testcase_11 AC 6 ms
8,192 KB
testcase_12 AC 102 ms
12,928 KB
testcase_13 AC 106 ms
12,800 KB
testcase_14 AC 98 ms
12,800 KB
testcase_15 AC 105 ms
12,800 KB
testcase_16 AC 100 ms
12,672 KB
testcase_17 AC 96 ms
12,672 KB
testcase_18 AC 95 ms
12,672 KB
testcase_19 AC 100 ms
12,928 KB
testcase_20 AC 96 ms
12,672 KB
testcase_21 AC 94 ms
12,672 KB
testcase_22 AC 106 ms
13,184 KB
testcase_23 AC 5 ms
8,192 KB
testcase_24 AC 5 ms
8,192 KB
testcase_25 AC 5 ms
8,192 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