結果

問題 No.568 じゃんじゃん 落とす 委員会
ユーザー vjudge1
提出日時 2025-05-17 16:51:46
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,154 bytes
コンパイル時間 6,392 ms
コンパイル使用メモリ 208,520 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-05-17 16:51:56
合計ジャッジ時間 7,803 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'bool P(long long int, long long int, long long int)':
main.cpp:18:22: warning: 'cnt2' may be used uninitialized [-Wmaybe-uninitialized]
   18 |         return cnt2>=m;
      |                      ^
main.cpp:11:20: note: 'cnt2' was declared here
   11 |         }int cur=0,cnt2;
      |                    ^~~~
main.cpp: In function 'int main()':
main.cpp:54:25: warning: 'cnt2' may be used uninitialized [-Wmaybe-uninitialized]
   54 |                         if(P(i,mid,0)){
      |                         ^~
main.cpp:11:20: note: 'cnt2' was declared here
   11 |         }int cur=0,cnt2;
      |                    ^~~~
main.cpp:43:33: warning: 'cnt2' may be used uninitialized [-Wmaybe-uninitialized]
   43 |                                 if(P(i,mid,1)){
      |                                 ^~
main.cpp:11:20: note: 'cnt2' was declared here
   11 |         }int cur=0,cnt2;
      |                    ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int xx[N],a[N],b[N];
int n,m,ans=LLONG_MAX;
bool P(int x,int y,int f)
{
	if(f==1){
		int t=y;y=x;x=t;
	}int cur=0,cnt2;
	for(int i=1;i<=n;++i){
		cur=xx[i];
		cur+=(a[i]>=x);
		cur+=(b[i]>=y);
		cnt2+=(cur>=2);
	}
	return cnt2>=m;
}
int sc(int x,int y,int f){
	if(f==1){
		int t=y;y=x;x=t;
	}int res=0,now=0;
	for(int i=1;i<=n;++i)	{
		now=xx[i];
		now+=(a[i]>=x);
		now+=(b[i]>=y);
		res+=(now>=3);
	}return res;
}signed main(){
	freopen("difficulty.in","r",stdin);
	freopen("difficulty.out","w",stdout);
	cin>>n>>m;
	int mxa=-1,mxb=-1;
	for(int i=1;i<=n;++i){
		cin>>xx[i]>>a[i]>>b[i];
		mxa=max(mxa,a[i]);mxb=max(mxb,b[i]);
	}if(mxb>mxa){
		for(int i=1;i<=mxb+1;++i){
			int l=0,r=mxa+1,res=0;
			while(l<=r){
				int mid=l+(r-l)/2;
				if(P(i,mid,1)){
					res=mid;
					l=mid+1;
				}else r=mid-1;
			}ans=min(ans,sc(i,res,1));
		}cout<<ans;
		return 0;
	}for(int i=1;i<=mxa+1;++i){
		int l=0,r=mxb+1,res=0;
		while(l<=r){
			int mid=l+(r-l)/2;
			if(P(i,mid,0)){
				res=mid;
				l=mid+1;
			}else r=mid-1;
		}ans=min(ans,sc(i,res,0));
	}cout<<ans;
	return 0;
}
0