結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー vjudge1
提出日時 2025-05-17 16:54:22
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 135 ms / 1,000 ms
コード長 968 bytes
コンパイル時間 3,296 ms
コンパイル使用メモリ 278,000 KB
実行使用メモリ 14,672 KB
最終ジャッジ日時 2025-05-17 16:54:29
合計ジャッジ時間 6,182 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define I using
#define AK namespace
#define CSPS2025 std
I AK CSPS2025;
const int maxn=1e5+10,maxm=1e3+10,mod=998244353,inf=1e18;
int n,m,u,v,w,l,r,L,R,res,ans=inf,arr[maxn],x[maxn],y[maxn],cnt[10];
vector<int>cnx[maxn],cny[maxn];
signed main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i]>>x[i]>>y[i];
		arr[i]++;cnt[arr[i]]++;
		cnx[x[i]].push_back(i);cny[y[i]].push_back(i);
		R=max(R,y[i]);
	}
	r=R+1;
	for(int l=0;l<=R+1;l++)
	{
		while(r)
		{
			if(cnt[2]+cnt[3]+cnt[4]+cnt[5]>=m)
			{
				break;
			}
			r--;
			for(int i:cny[r])
			{
				cnt[arr[i]]--;
				arr[i]++;
				cnt[arr[i]]++;
			}
		}
		if(cnt[2]+cnt[3]+cnt[4]+cnt[5]<m)
		{
			break;
		}
		ans=min(ans,cnt[3]+cnt[4]+cnt[5]);
		for(int i:cnx[l])
		{
			cnt[arr[i]]--;
			arr[i]--;
			cnt[arr[i]]++;
		}
		/*
		l++
		res-=cnx[l]
		r--
		res+=cny[r]
		*/
	}
	cout<<ans;
	return 0;
}

0