結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー Kazuki TakehiKazuki Takehi
提出日時 2023-10-07 14:53:43
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,677 bytes
コンパイル時間 2,838 ms
コンパイル使用メモリ 249,024 KB
実行使用メモリ 14,388 KB
最終ジャッジ日時 2023-10-07 14:53:48
合計ジャッジ時間 5,088 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
14,276 KB
testcase_01 AC 56 ms
14,264 KB
testcase_02 AC 5 ms
8,168 KB
testcase_03 AC 4 ms
8,428 KB
testcase_04 AC 6 ms
8,176 KB
testcase_05 AC 5 ms
8,300 KB
testcase_06 AC 4 ms
8,292 KB
testcase_07 AC 5 ms
8,168 KB
testcase_08 AC 4 ms
8,212 KB
testcase_09 AC 5 ms
8,224 KB
testcase_10 AC 4 ms
8,436 KB
testcase_11 AC 5 ms
8,220 KB
testcase_12 AC 64 ms
14,008 KB
testcase_13 AC 59 ms
14,128 KB
testcase_14 AC 55 ms
14,128 KB
testcase_15 AC 57 ms
14,056 KB
testcase_16 AC 56 ms
13,860 KB
testcase_17 AC 59 ms
13,740 KB
testcase_18 AC 53 ms
13,688 KB
testcase_19 AC 54 ms
14,128 KB
testcase_20 AC 54 ms
14,004 KB
testcase_21 AC 54 ms
13,740 KB
testcase_22 WA -
testcase_23 AC 5 ms
8,296 KB
testcase_24 AC 4 ms
8,368 KB
testcase_25 AC 4 ms
8,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fore(i,a) for(auto &i:a)
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define rrep(i,a,b) for(ll i = a; i >= b; i--)
#define all(obj) (obj).begin(), (obj).end()
using Pl = pair<ll, ll>;
using Pi = pair<int, int>;
using Vl = vector<ll>;
using VVl = vector<Vl>;
using Vi = vector<int>;
using VVi = vector<Vi>;
using Vb = vector<bool>;
using VVb = vector<Vb>;
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
const int inf = INT_MAX / 2;
const ll infl = 1LL << 62;
template <class T, class U>
bool chmax(T &a, const U &b) { return a < b ? (a = b, 1) : 0; }
template <class T, class U>
bool chmin(T &a, const U &b) { return a > b ? (a = b, 1) : 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const ll  MAX_DIFF = 101010;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  ll  n, m; cin >> n >> m;
  Vl  x(n), a(n), b(n);
  Vl  A[MAX_DIFF], B[MAX_DIFF];
  Vl  cnt(6, 0);
  rep(i, 0, n) {
    cin >> x[i] >> a[i] >> b[i];
    A[a[i]].push_back(i);
    B[b[i]].push_back(i);
  }
  rep(i, 0, n)
    cnt[++x[i]]++;
  ll  ans = infl, sb = 100001;
  for (ll sa = 0; sa <= 100000; sa++) {
    while (cnt[2] + cnt[3] + cnt[4] + cnt[5] < m and sb > 0) {
      sb--;
      fore(i, B[sb]) {
        cnt[x[i]]--;
        x[i]++;
        cnt[x[i]]++;
      }
    }
    if (cnt[2] + cnt[3] + cnt[4] + cnt[5] < m) break;
    chmin(ans, cnt[3] + cnt[4] + cnt[5]);
    fore(i, A[sa]) {
      cnt[x[i]]--;
      x[i]--;
      cnt[x[i]]++;
    }
  }
  if (ans == infl) cout << 0 << endl;
  else cout << ans << endl;

  return 0;
}
0