답안 #10093

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
10093 2014-10-12T04:16:39 Z gs14004 대표 선수 (KOI11_player) C++
20 / 20
292 ms 13504 KB
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>
using namespace std;
typedef pair<int,int> pi;

vector<pi> a;
int n,m;
int v[1005], cnt;

int main(){
    int t;
    scanf("%d %d",&n,&m);
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            scanf("%d",&t);
            a.push_back(pi(t,i+1));
        }
    }
    sort(a.begin(),a.end());
    int ep = 0;
    int res = 1e9;
    for (int i=0; i<a.size(); i++) {
        while (cnt < n && ep < a.size()) {
            if(v[a[ep].second] == 0) cnt++;
            v[a[ep].second]++;
            ep++;
        }
        if(ep == a.size()) break;
        res = min(res,a[ep-1].first - a[i].first);
        if(v[a[i].second] == 1) cnt--;
        v[a[i].second]--;
    }
    printf("%d",res);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1212 KB Output is correct
2 Correct 0 ms 1212 KB Output is correct
3 Correct 0 ms 1212 KB Output is correct
4 Correct 0 ms 1212 KB Output is correct
5 Correct 0 ms 1212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1212 KB Output is correct
2 Correct 8 ms 1600 KB Output is correct
3 Correct 24 ms 2752 KB Output is correct
4 Correct 60 ms 4288 KB Output is correct
5 Correct 72 ms 4288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 7360 KB Output is correct
2 Correct 84 ms 7360 KB Output is correct
3 Correct 104 ms 7360 KB Output is correct
4 Correct 120 ms 7360 KB Output is correct
5 Correct 128 ms 7360 KB Output is correct
6 Correct 164 ms 13504 KB Output is correct
7 Correct 204 ms 13504 KB Output is correct
8 Correct 208 ms 13504 KB Output is correct
9 Correct 248 ms 13504 KB Output is correct
10 Correct 292 ms 13504 KB Output is correct