結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー Kazuki TakehiKazuki Takehi
提出日時 2023-10-07 14:52:50
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,634 bytes
コンパイル時間 3,029 ms
コンパイル使用メモリ 251,648 KB
実行使用メモリ 14,732 KB
最終ジャッジ日時 2024-07-26 17:49:22
合計ジャッジ時間 5,781 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 WA * 1
権限があれば一括ダウンロードができます

ソースコード

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]]++;
    }
  }
  cout << ans << endl;

  return 0;
}
0