| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 236425 | GioChkhaidze | The Kingdom of JOIOI (JOI17_joioi) | C++14 | 1054 ms | 70648 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N=2004;
int n,m,Max,Min,ans;
int a[N][N],b[N][N];
bool check(int x) {
int Col=0;
for (int i=1; i<=n; i++) {
for (int j=1; j<=m; j++)
if (Max-x>a[i][j]) Col=max(Col,j);
for (int j=1; j<=Col; j++)
if (Min+x<a[i][j]) return false;
}
return true;
}
void G() {
int l=0,r=Max-Min,mid,res=-1;
while (l<=r) {
mid=(l+r)/2;
if (check(mid))
r=mid-1,res=mid;
else
l=mid+1;
}
if (res==-1) return ;
ans=min(ans,res);
}
void Rotate() {
for (int i=1; i<=n; i++)
for (int j=1; j<=m; j++)
b[i][j]=a[i][j];
for (int i=1; i<=m; i++)
for (int j=1; j<=n; j++)
a[i][j]=b[j][m-i+1];
swap(n,m);
}
main () {
ios::sync_with_stdio(false);
cin.tie(NULL),cout.tie(NULL);
cin>>n>>m;
Max=-1e9,Min=1e9;
for (int i=1; i<=n; i++)
for (int j=1; j<=m; j++) {
cin>>a[i][j];
Max=max(Max,a[i][j]);
Min=min(Min,a[i][j]);
}
ans=1e9;
G();
Rotate(); G();
Rotate(); G();
Rotate(); G();
cout<<ans<<"\n";
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
