結果
問題 | No.2157 崖 |
ユーザー |
![]() |
提出日時 | 2022-12-09 21:36:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 1,916 ms / 6,000 ms |
コード長 | 1,053 bytes |
コンパイル時間 | 4,449 ms |
コンパイル使用メモリ | 255,240 KB |
最終ジャッジ日時 | 2025-02-09 07:34:00 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:26:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 26 | rep(j,m)scanf("%lld",&a[i][j]); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#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; }