結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー KKT89KKT89
提出日時 2019-06-17 21:56:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 109 ms / 1,000 ms
コード長 1,062 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 73,860 KB
実行使用メモリ 12,808 KB
最終ジャッジ日時 2023-08-19 09:20:45
合計ジャッジ時間 3,997 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
12,676 KB
testcase_01 AC 107 ms
12,808 KB
testcase_02 AC 5 ms
8,060 KB
testcase_03 AC 5 ms
8,204 KB
testcase_04 AC 5 ms
8,060 KB
testcase_05 AC 5 ms
8,320 KB
testcase_06 AC 6 ms
8,056 KB
testcase_07 AC 5 ms
8,020 KB
testcase_08 AC 5 ms
8,012 KB
testcase_09 AC 5 ms
8,028 KB
testcase_10 AC 5 ms
8,060 KB
testcase_11 AC 5 ms
8,060 KB
testcase_12 AC 105 ms
12,524 KB
testcase_13 AC 107 ms
12,732 KB
testcase_14 AC 108 ms
12,512 KB
testcase_15 AC 108 ms
12,512 KB
testcase_16 AC 106 ms
12,424 KB
testcase_17 AC 102 ms
12,400 KB
testcase_18 AC 105 ms
12,428 KB
testcase_19 AC 105 ms
12,524 KB
testcase_20 AC 101 ms
12,444 KB
testcase_21 AC 101 ms
12,472 KB
testcase_22 AC 109 ms
12,796 KB
testcase_23 AC 5 ms
8,336 KB
testcase_24 AC 5 ms
8,256 KB
testcase_25 AC 5 ms
8,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int cnt[6];//完答数に応じて人数をカウントする
vector<int> a1[100010],b1[100010]; //SAとAi、SBとBiを対応させる配列
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 SB=100001;
  for(int SA=0;SA<100002;SA++){
    while(cnt[2]+cnt[3]+cnt[4]+cnt[5]<m){
      SB--;
      if(SB<0)break;
      for(auto i:b1[SB]){
        //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[SA]){
      //A問題の難易度が上がるのでここで処理しておく
      cnt[x[i]]--;
      x[i]--;
      cnt[x[i]]++;
    }
  }
  cout << ans << endl;
}
0