結果
問題 | No.2248 max(C)-min(C) |
ユーザー |
|
提出日時 | 2023-04-20 23:31:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 693 bytes |
コンパイル時間 | 2,097 ms |
コンパイル使用メモリ | 197,564 KB |
最終ジャッジ日時 | 2025-02-12 10:38:02 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 6 WA * 45 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef long long ll;#define rep(i,l,r) for(int i=(l);i<(r);++i)int main(){ll n; cin>>n;vector<vector<ll>> g(3,vector<ll> (n));rep(i,0,n) cin>>g[0][i];rep(i,0,n) cin>>g[1][i];rep(i,0,n) g[2][i]=(g[0][i]+g[1][i])/2;vector<vector<ll>> dp(3,vector<ll> (n));dp[0][0]=g[0][0]; dp[1][0]=g[1][0]; dp[2][0]=g[2][0];rep(i,1,n){rep(j,0,3){ll mn=1e9, id=0;rep(k,0,3){if(mn>abs(dp[j][i-1]-g[k][i])) {mn=abs(dp[j][i-1]-g[k][i]), id=k;}}dp[j][i]=g[id][i];}}ll ans=1e9;rep(i,0,3){ll mx=0, mn=1e9;rep(j,0,n){mx=max(mx,dp[i][j]);mn=min(mn,dp[i][j]);}ans=min(ans,mx-mn);}cout<<ans<<endl;}