# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
124556 | wilwxk | The Kingdom of JOIOI (JOI17_joioi) | C++14 | 928 ms | 70628 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN=2e3+5;
int v[3][MAXN][MAXN];
int n, m, maior, menor;
bool testa(int val, int k) {
vector<pair<int, int> > inter;
for(int i=1; i<=n; i++) {
int a=m+1, b=0;
while(a-1>=1&&v[k][i][a-1]>=maior-val) a--;
while(b+1<=m&&v[k][i][b+1]<=menor+val) b++;
a--; if(a>b) return 0;
inter.push_back({a, b});
}
bool ok=1, ok2=1;
int ult=0, ult2=m+1;
for(auto cur : inter) {
if(cur.second<ult) ok=0;
if(cur.first>ult2) ok2=0;
ult=max(ult, cur.first);
ult2=min(ult2, cur.second);
}
return (ok||ok2);
}
bool testa2(int k) {
return (testa(k, 1)||testa(k, 2));
}
int main() {
scanf("%d %d", &n, &m);
maior=-1; menor=1e9+9;
for(int i=1; i<=n; i++) {
for(int j=1; j<=m; j++) {
scanf("%d", &v[1][i][j]);
v[2][i][m-j+1]=v[1][i][j];
maior=max(maior, v[1][i][j]);
menor=min(menor, v[1][i][j]);
}
}
int respf=0;
// testa(11, 1);
for(int i=maior; i>0; i/=2) while(respf+i<=maior&&!testa2(respf+i)) respf+=i;
printf("%d\n", respf+1);
}
컴파일 시 표준 에러 (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... |