結果
問題 | No.2248 max(C)-min(C) |
ユーザー | umimel |
提出日時 | 2023-03-17 22:43:58 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,364 bytes |
コンパイル時間 | 1,747 ms |
コンパイル使用メモリ | 169,408 KB |
実行使用メモリ | 7,960 KB |
最終ジャッジ日時 | 2024-09-18 11:52:29 |
合計ジャッジ時間 | 5,402 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 3 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | WA | - |
testcase_13 | AC | 3 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 3 ms
5,376 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | AC | 48 ms
7,188 KB |
testcase_19 | AC | 8 ms
5,376 KB |
testcase_20 | AC | 55 ms
7,836 KB |
testcase_21 | AC | 51 ms
7,552 KB |
testcase_22 | AC | 37 ms
6,272 KB |
testcase_23 | AC | 24 ms
5,376 KB |
testcase_24 | AC | 11 ms
5,376 KB |
testcase_25 | AC | 50 ms
7,424 KB |
testcase_26 | AC | 44 ms
6,912 KB |
testcase_27 | AC | 49 ms
7,384 KB |
testcase_28 | AC | 6 ms
5,376 KB |
testcase_29 | WA | - |
testcase_30 | AC | 20 ms
5,376 KB |
testcase_31 | AC | 54 ms
7,828 KB |
testcase_32 | WA | - |
testcase_33 | AC | 18 ms
5,376 KB |
testcase_34 | AC | 55 ms
7,832 KB |
testcase_35 | AC | 55 ms
7,956 KB |
testcase_36 | AC | 55 ms
7,948 KB |
testcase_37 | AC | 29 ms
5,644 KB |
testcase_38 | AC | 49 ms
7,836 KB |
testcase_39 | AC | 49 ms
7,832 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | AC | 49 ms
7,828 KB |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | AC | 38 ms
6,912 KB |
testcase_46 | AC | 21 ms
5,376 KB |
testcase_47 | AC | 48 ms
7,828 KB |
testcase_48 | AC | 42 ms
7,832 KB |
testcase_49 | AC | 52 ms
7,836 KB |
testcase_50 | AC | 54 ms
7,836 KB |
testcase_51 | AC | 53 ms
7,836 KB |
testcase_52 | AC | 53 ms
7,960 KB |
testcase_53 | AC | 10 ms
5,376 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second const ll MOD = 1000000007; const ll MOD2 = 998244353; const ll INF = 1LL << 60; const ll MAX_N = 2e5; ll n; vector<ll> a, b; ll solve(ll base){ vector<ll> c(n, 0); c[0] = base; for(ll i=1; i<n; i++){ ll diff = INF, v = INF; if(abs(a[i]-base) < diff){ diff = abs(a[i]-base); v = a[i]; } if(abs(b[i]-base) < diff){ diff = abs(b[i]-base); v = b[i]; } if(abs((a[i]+b[i])/2-base) < diff){ diff = abs((a[i]+b[i])/2-base); v = (a[i]+b[i])/2; } c[i] = v; } ll c_max = -INF, c_min = INF; rep(i, n){ c_max = max(c_max, c[i]); c_min = min(c_min, c[i]); } return c_max-c_min; } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin >> n; a.resize(n); b.resize(n); rep(i, n) cin >> a[i]; rep(i, n) cin >> b[i]; ll ans = INF; ans = min(ans, solve(a[0])); ans = min(ans, solve(b[0])); ans = min(ans, solve((a[0]+b[0])/2)); cout << ans << endl; }