Submission #20191

#TimeUsernameProblemLanguageResultExecution timeMemory
20191exqt대표 선수 (KOI11_player)C++98
16 / 20
545 ms64 KiB
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <utility> #include <queue> #include <string> #include <cstring> using namespace std; #define in cin #define out cout #define all(v) v.begin(), v.end() #define X first #define Y second int CNT[1010]; int main() { int n, m; in >> n >> m; vector< pair<int, int> > v; for(int i=0; i<n; i++) { for(int j=0; j<m; j++) { int x; in >> x; v.push_back(make_pair(x, i)); } } sort(all(v)); int q = 0; int K = 0; int res = 101010101; for(int p=0; p<n*m; p++) { if(CNT[ v[p].Y ] == 0) K++; CNT[ v[p].Y ]++; while(K == n) { if(v[p].X - v[q].X < res) res = v[p].X - v[q].X; CNT[ v[q].Y ]--; if(CNT[ v[q].Y ] == 0) K--; q++; } } int p = n*m-1; while(K == n) { if(v[p].X - v[q].X < res) res = v[p].X - v[q].X; CNT[ v[q].Y ]--; if(CNT[ v[q].Y ] == 0) K--; q++; } out << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...