제출 #1001

#제출 시각아이디문제언어결과실행 시간메모리
1001tncks0121대표 선수 (KOI11_player)C++98
20 / 20
268 ms8904 KiB
#include<stdio.h> #include<algorithm> using namespace std; #define N_ 1000 int N, M; struct S1{ int x, dat; bool operator< (const S1 &t) const { return dat < t.dat; } }D[N_*N_+1]; int Chk [N_+1], cnt; int res = 2147483647; int main(){ int i, j; scanf("%d%d",&N,&M); for(i=1; i<=N; i++){ for(j=1; j<=M; j++){ int v = (i-1) * M + j; scanf("%d",&D[v].dat); D[v].x = i; } } sort(D+1, D+N*M+1); Chk[D[1].x] ++; cnt ++; for(i=j=1; i<=N*M && j<=N*M; ){ if(cnt == N){ if(D[j].dat - D[i].dat < res) res = D[j].dat - D[i].dat; if(Chk[D[i].x] == 1) cnt --; Chk[D[i].x] --; i++; continue; } if(Chk[D[i].x] > 1 && i+1 <= j){ Chk[D[i].x] --; i++; } else{ j++; if(!Chk[D[j].x]) cnt++; Chk[D[j].x]++; } } printf("%d\n",res); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...