답안 #16246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16246 2015-08-18T11:21:22 Z eaststar 대표 선수 (KOI11_player) C++14
20 / 20
274 ms 8900 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
struct Data{
    int c,p;
    bool operator<(const Data&r)const{
        return p<r.p;
    }
}a[1000010];
int chk[1010],ans=1<<30,f=0,r=-1,flag;
int main(){
    int i,j,n,m,t;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;++i){
        for(j=0;j<m;++j){
            scanf("%d",&a[i*m+j].p);
            a[i*m+j].c=i+1;
        }
    }
    std::sort(a,a+n*m);
    while(r<n*m-1){
        if(flag==n){
            ans=min(ans,a[r].p-a[f].p);
            chk[a[f].c]--;
            if(!chk[a[f].c])flag--;
            ++f;
        }
        else{
            chk[a[++r].c]++;
            if(chk[a[r].c]==1)flag++;
        }
    }
    printf("%d",ans);
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 8900 KB Output is correct
2 Correct 0 ms 8900 KB Output is correct
3 Correct 0 ms 8900 KB Output is correct
4 Correct 0 ms 8900 KB Output is correct
5 Correct 0 ms 8900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8900 KB Output is correct
2 Correct 10 ms 8900 KB Output is correct
3 Correct 30 ms 8900 KB Output is correct
4 Correct 60 ms 8900 KB Output is correct
5 Correct 70 ms 8900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 8900 KB Output is correct
2 Correct 107 ms 8900 KB Output is correct
3 Correct 127 ms 8900 KB Output is correct
4 Correct 113 ms 8900 KB Output is correct
5 Correct 90 ms 8900 KB Output is correct
6 Correct 147 ms 8900 KB Output is correct
7 Correct 140 ms 8900 KB Output is correct
8 Correct 191 ms 8900 KB Output is correct
9 Correct 224 ms 8900 KB Output is correct
10 Correct 274 ms 8900 KB Output is correct