#include<cstdio>
#include<algorithm>
#include<set>
struct student
{
int x;
int y;
int z;
} s[1000][1000],t;
inline bool operator <(const student &a,const student &b)
{
if(a.x!=b.x)return a.x<b.x;
if(a.y!=b.y)return a.y<b.y;
return a.z<b.z;
}
std::set<student> S;
std::set<student>::iterator it1,it2;
int main()
{
int min=1e9;
int i,j,n,m;
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf("%d",&s[i][j].x);
s[i][j].y=i;
s[i][j].z=j;
}
std::sort(s[i],s[i]+m);
}
for(i=0;i<n;i++)S.insert(s[i][0]);
for(i=n;i<n*m;i++)
{
it1=S.begin();
it2=S.end();
it2--;
if(it2->x-it1->x<min)
min=it2->x-it1->x;
if(it1->z+1==m)break;
S.insert(s[it1->y][it1->z+1]);
S.erase(it1);
}
printf("%d",min);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
12928 KB |
Output isn't correct |
2 |
Incorrect |
0 ms |
12928 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
12928 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
12928 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
12928 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
12928 KB |
Output isn't correct |
2 |
Incorrect |
4 ms |
12928 KB |
Output isn't correct |
3 |
Incorrect |
20 ms |
12928 KB |
Output isn't correct |
4 |
Incorrect |
48 ms |
12928 KB |
Output isn't correct |
5 |
Incorrect |
60 ms |
12928 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
76 ms |
12928 KB |
Output isn't correct |
2 |
Incorrect |
64 ms |
12928 KB |
Output isn't correct |
3 |
Incorrect |
84 ms |
12928 KB |
Output isn't correct |
4 |
Incorrect |
96 ms |
12928 KB |
Output isn't correct |
5 |
Incorrect |
112 ms |
12928 KB |
Output isn't correct |
6 |
Incorrect |
112 ms |
12928 KB |
Output isn't correct |
7 |
Incorrect |
152 ms |
12928 KB |
Output isn't correct |
8 |
Incorrect |
168 ms |
12928 KB |
Output isn't correct |
9 |
Incorrect |
188 ms |
12928 KB |
Output isn't correct |
10 |
Incorrect |
232 ms |
12928 KB |
Output isn't correct |