結果
| 問題 |
No.568 じゃんじゃん 落とす 委員会
|
| コンテスト | |
| ユーザー |
Tttt Yay
|
| 提出日時 | 2021-03-31 20:44:34 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 102 ms / 1,000 ms |
| コード長 | 1,715 bytes |
| コンパイル時間 | 4,167 ms |
| コンパイル使用メモリ | 254,684 KB |
| 最終ジャッジ日時 | 2025-01-20 02:17:54 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 26 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)(x).size())
#define PB push_back
#define MP make_pair
#define V vector
#define P pair<int,int>
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using ll = long long;
using ld = long double;
using namespace std;
const int INF =1001001001;
const int INFL =1<<30;
const int MAX = 2e6+1;
int main() {
int n,m;cin>>n>>m;
V<P> a(n),b(n);
V<int> x(n);
rep(i,n){
int x1,a1,b1;
cin>>x1>>a1>>b1;
x[i]=x1+1;
a[i]=MP(a1,i);
b[i]=MP(b1,i);
}
sort(all(a));
sort(all(b));
int anow=0,bnow=n-1;
int kan2=0,kan3=0;
rep(i,n){
if(x[i]>=2)kan2++;
if(x[i]>=3)kan3++;
}
int ans=INF;
rep(sa,100002){
while(anow<n&&a[anow].first<sa){
x[a[anow].second]--;
if(x[a[anow].second]==1)kan2--;
if(x[a[anow].second]==2)kan3--;
anow++;
}
while(bnow>=0&&kan2<m){
int t=b[bnow].first;
while(b[bnow].first==t){
x[b[bnow].second]++;
if(x[b[bnow].second]==2)kan2++;
if(x[b[bnow].second]==3)kan3++;
bnow--;
}
}
if(kan2>=m)chmin(ans,kan3);
}
cout<<ans<<endl;
return 0;
}
Tttt Yay