結果

問題 No.2157 崖
ユーザー 沙耶花沙耶花
提出日時 2022-12-09 21:36:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,698 ms / 6,000 ms
コード長 1,053 bytes
コンパイル時間 5,048 ms
コンパイル使用メモリ 260,144 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2024-04-22 21:13:34
合計ジャッジ時間 21,163 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,948 KB
testcase_13 AC 1,407 ms
13,824 KB
testcase_14 AC 1,375 ms
18,176 KB
testcase_15 AC 1,388 ms
13,696 KB
testcase_16 AC 1,360 ms
13,696 KB
testcase_17 AC 1,125 ms
15,872 KB
testcase_18 AC 1,090 ms
15,616 KB
testcase_19 AC 1,698 ms
16,384 KB
testcase_20 AC 1,459 ms
19,456 KB
testcase_21 AC 1,431 ms
19,584 KB
testcase_22 AC 1,081 ms
15,104 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 2000000000000000001

long long op(long long a,long long b){
	return min(a,b);
}

long long e(){
	return Inf64;
}

int main(){
	
	int n,m;
	cin>>n>>m;
	
	vector a(n,vector<long long> (m));
	rep(i,n){
		rep(j,m)scanf("%lld",&a[i][j]);
		sort(a[i].begin(),a[i].end());
	}
	
	long long ok = Inf32,ng = -1;
	while(ok-ng>1){
		int mid = (ok+ng)/2;
		vector<bool> f(m,true);
		for(int i=1;i<n;i++){
			vector<bool> nf(m,false);
			int l = 0,r = 0,s = 0;
			rep(j,m){
				while(r!=m && a[i-1][r]<=a[i][j]){
					if(f[r])s++;
					r++;
				}
				while(l!=m && a[i-1][l]<=a[i][j] && a[i][j]-a[i-1][l]>mid){
					if(f[l])s--;
					l++;
				}
				nf[j] = (s>0);
			}
			swap(f,nf);
		}
		bool F = false;
		rep(i,m){
			if(f[i])F = true;
		}
		if(F)ok = mid;
		else ng = mid;
		
	}
	if(ok==Inf32)ok = -1;
	cout<<ok<<endl;
	
	return 0;
}
0