Submission #1846

# Submission time Handle Problem Language Result Execution time Memory
1846 2013-07-18T12:58:10 Z alephnull 대표 선수 (KOI11_player) C++
12 / 20
1500 ms 1948 KB
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int n,m;scanf("%d %d",&n,&m);
	int a[n][m];
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			scanf("%d",&a[i][j]);
	for(int i=0;i<n;i++)
		sort(a[i],a[i]+m);
	int ans=987654321;
	int p[n];
	for(int i=0;i<n;i++)p[i]=0;
	int cnt=0;
	while(cnt!=n*(m-1)){
		int min=0,max=0;
		for(int i=0;i<n;i++){
			if(a[i][p[i]]<a[min][p[min]])min=i;
			if(a[i][p[i]]>a[max][p[max]])max=i;
		}
		//printf("%d %d\n",min,max);
		if(ans>a[max][p[max]]-a[min][p[min]])ans=a[max][p[max]]-a[min][p[min]];
		if(p[min]==m-1)break;
		p[min]++;
		cnt++;
	}
	printf("%d",ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 884 KB Output is correct
2 Correct 0 ms 884 KB Output is correct
3 Correct 0 ms 884 KB Output is correct
4 Correct 0 ms 884 KB Output is correct
5 Correct 0 ms 884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 884 KB Output is correct
2 Correct 37 ms 908 KB Output is correct
3 Correct 228 ms 1128 KB Output is correct
4 Correct 912 ms 1620 KB Output is correct
5 Correct 1203 ms 1788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1485 ms 1948 KB Output is correct
2 Correct 1410 ms 1896 KB Output is correct
3 Execution timed out 1500 ms 0 KB Program timed out
4 Execution timed out 1500 ms 0 KB Program timed out
5 Execution timed out 1500 ms 0 KB Program timed out
6 Execution timed out 1500 ms 0 KB Program timed out
7 Execution timed out 1500 ms 0 KB Program timed out
8 Execution timed out 1500 ms 0 KB Program timed out
9 Execution timed out 1500 ms 0 KB Program timed out
10 Execution timed out 1500 ms 0 KB Program timed out