Submission #1724918


Source Code Expand

#include<bits/stdc++.h>
#define ll long long
#define FOr(i,x,y)  for(ll i=x;i>=y;--i)
#define For(i,x,y)	for(ll i=x;i<=y;++i)
using namespace std;
namespace SHENZHEBEI{
#ifdef LOCAL
	struct szb{	szb(){	freopen("shenzhebei.in","r",stdin);	}	}shenzhebei;
#endif
#define NEG 1
	const int L=2333333;
	char SZB[L],*S=SZB,*T=SZB;
	inline char gc(){	if (S==T){	T=(S=SZB)+fread(SZB,1,L,stdin);	if (S==T) return '\n';	}	return *S++;	}
#if NEG
	inline ll readint(){	ll x=0,f=1;	char ch=gc();	for (;!isdigit(ch);ch=gc())	if (ch=='-') f=-1;	for (;isdigit(ch);ch=gc())	x=x*10-48+ch;	return x*f;	}
	inline void write(ll x){	if (x<0)	putchar('-'),x=-x;	if (x>=10)	write(x/10);	putchar(x%10+'0');	}
#else
	inline ll readint(){	ll x=0;	char ch=gc();	for (;!isdigit(ch);ch=gc());	for (;isdigit(ch);ch=gc())	x=x*10-48+ch;	return x;	}
	inline void write(ll x){	if (x>=10)	write(x/10);	putchar(x%10+'0');	}
#endif
	inline char readchar(){	char ch=gc();	for(;isspace(ch);ch=gc());	return ch;	}
	inline ll readstr(char *s){	char ch=gc();	int cur=0;	for(;isspace(ch);ch=gc());		for(;!isspace(ch);ch=gc())	s[cur++]=ch;	s[cur]='\0';	return cur;	}
	inline void writeln(ll x){	write(x);	puts("");	}
}using namespace SHENZHEBEI;
const ll N=310;
ll a[N][N],vis[N],sum[N],cho[N],n,m,ans,del[N];
int main(){
	n=readint();	m=readint();
	For(i,1,n)	For(j,1,m)	a[i][j]=readint();
	For(i,1,n)	cho[i]=1,ans=max(ans,++sum[a[i][1]]);
	while(1){
		ll c=0;
		For(i,1,m)	if (sum[i]>sum[c])	c=i;
		ans=min(ans,sum[c]);	del[c]=1;
		For(i,1,n){
			while(del[a[i][cho[i]]]){
				sum[a[i][cho[i]]]--;
				cho[i]++;
				sum[a[i][cho[i]]]++;
			}
			if (cho[i]>m)	return writeln(ans),0;
		}
	}
	writeln(ans);
}

Submission Info

Submission Time
Task B - Sports Festival
User vjudge4
Language C++14 (GCC 5.4.1)
Score 700
Code Size 1661 Byte
Status AC
Exec Time 3 ms
Memory 1280 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 3
AC × 24
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_01.txt, sample_02.txt, sample_03.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt, subtask_1_09.txt, subtask_1_10.txt, subtask_1_11.txt, subtask_1_12.txt, subtask_1_13.txt, subtask_1_14.txt, subtask_1_15.txt, subtask_1_16.txt, subtask_1_17.txt, subtask_1_18.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
subtask_1_01.txt AC 1 ms 256 KB
subtask_1_02.txt AC 1 ms 512 KB
subtask_1_03.txt AC 1 ms 384 KB
subtask_1_04.txt AC 1 ms 512 KB
subtask_1_05.txt AC 1 ms 512 KB
subtask_1_06.txt AC 2 ms 1024 KB
subtask_1_07.txt AC 2 ms 1024 KB
subtask_1_08.txt AC 2 ms 1024 KB
subtask_1_09.txt AC 1 ms 1024 KB
subtask_1_10.txt AC 1 ms 384 KB
subtask_1_11.txt AC 2 ms 384 KB
subtask_1_12.txt AC 1 ms 256 KB
subtask_1_13.txt AC 2 ms 512 KB
subtask_1_14.txt AC 3 ms 1280 KB
subtask_1_15.txt AC 3 ms 1280 KB
subtask_1_16.txt AC 3 ms 1280 KB
subtask_1_17.txt AC 3 ms 1280 KB
subtask_1_18.txt AC 3 ms 1280 KB