結果

問題 No.2157 崖
ユーザー ゆにぽけゆにぽけ
提出日時 2024-01-26 16:56:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,929 bytes
コンパイル時間 1,533 ms
コンパイル使用メモリ 135,216 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-01-26 16:56:31
合計ジャッジ時間 9,215 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 WA -
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 WA -
testcase_12 AC 2 ms
6,676 KB
testcase_13 WA -
testcase_14 AC 357 ms
10,752 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 329 ms
9,728 KB
testcase_18 AC 297 ms
9,472 KB
testcase_19 WA -
testcase_20 AC 411 ms
11,520 KB
testcase_21 AC 426 ms
11,392 KB
testcase_22 AC 285 ms
9,216 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <iterator>
#include <string>
#include <cctype>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <ctime>
#include <iomanip>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <random>
#include <utility>
#include <functional>
using namespace std;
void Main()
{
	int N,M;
	cin >> N >> M;
	vector<vector<int>> D(N,vector<int>(M));
	for(int i = 0;i < N;i++)
	{
		for(int j = 0;j < M;j++)
		{
			cin >> D[i][j];
		}
		sort(D[i].begin(),D[i].end());
	}
	int ans = (int)2e9;
	for(int j = 0;j < M;j++)
	{
		int val = D[0][j];
		int mx = 0;
		for(int i = 1;i < N;i++)
		{
			auto it = lower_bound(D[i].begin(),D[i].end(),val);
			if(it == D[i].end())
			{
				mx = (int)2e9;
				break;
			}
			mx = max(mx,*it - val);
			val = *it;
		}
		ans = min(ans,mx);
	}
	if(ans == (int)2e9)
	{
		ans = -1;
	}
	cout << ans << endl;
	/* int K = 0; */
	/* while(1 << K < N) */
	/* { */
	/* 	K++; */
	/* } */
	/* vector<vector<vector<int>>> dp(N - 1,vector<vector<int>>(M,vector<int>(K + 1,(int)2e9))); */
	/* vector<vector<vector<int>>> to(N - 1,vector<vector<int>>(M,vector<int>(K + 1,-1))); */
	/* for(int i = 0;i + 1 < N;i++) */
	/* { */
	/* 	int k = 0; */
	/* 	for(int j = 0;j < M;j++) */
	/* 	{ */
	/* 		while(k < M && D[i][j] < D[i + 1][k]) */
	/* 		{ */
	/* 			k++; */
	/* 		} */
	/* 		if(k < M) */
	/* 		{ */
	/* 			dp[i][j][0] = D[i + 1][k] - D[i][j]; */
	/* 			to[i][j][0] = (i + 1) * M + k; */
	/* 		} */
	/* 	} */
	/* } */
	/* for(int k = 1;k <= K;k++) */
	/* { */
	/* 	for(int i = 0;i + (1 << k) < N;i++) */
	/* 	{ */
	/* 		for(int j = 0;j < M;j++) */
	/* 		{ */
	/* 		} */
	/* 	} */
	/* } */
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int tt = 1;
	/* cin >> tt; */
	while(tt--) Main();
}
0