結果
| 問題 |
No.2248 max(C)-min(C)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-04-20 23:29:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 701 bytes |
| コンパイル時間 | 2,172 ms |
| コンパイル使用メモリ | 199,380 KB |
| 最終ジャッジ日時 | 2025-02-12 10:36:50 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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(){
int n; cin>>n;
vector<vector<int>> g(3,vector<int> (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<int>> dp(3,vector<int> (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){
int 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];
}
}
int ans=1e9;
rep(i,0,3){
int 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;
}