結果

問題 No.2248 max(C)-min(C)
ユーザー 沙耶花沙耶花
提出日時 2023-03-17 21:38:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 875 ms / 3,000 ms
コード長 789 bytes
コンパイル時間 4,587 ms
コンパイル使用メモリ 272,216 KB
実行使用メモリ 20,680 KB
最終ジャッジ日時 2023-10-18 14:09:36
合計ジャッジ時間 23,204 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 4 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 5 ms
4,348 KB
testcase_07 AC 5 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 5 ms
4,348 KB
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 5 ms
4,348 KB
testcase_18 AC 417 ms
17,176 KB
testcase_19 AC 40 ms
5,140 KB
testcase_20 AC 492 ms
20,680 KB
testcase_21 AC 459 ms
19,996 KB
testcase_22 AC 294 ms
14,408 KB
testcase_23 AC 170 ms
10,096 KB
testcase_24 AC 61 ms
6,028 KB
testcase_25 AC 450 ms
19,340 KB
testcase_26 AC 385 ms
16,176 KB
testcase_27 AC 452 ms
19,308 KB
testcase_28 AC 32 ms
4,844 KB
testcase_29 AC 399 ms
16,520 KB
testcase_30 AC 132 ms
8,648 KB
testcase_31 AC 512 ms
20,680 KB
testcase_32 AC 70 ms
6,388 KB
testcase_33 AC 123 ms
8,336 KB
testcase_34 AC 511 ms
20,680 KB
testcase_35 AC 532 ms
20,680 KB
testcase_36 AC 509 ms
20,680 KB
testcase_37 AC 221 ms
12,640 KB
testcase_38 AC 614 ms
20,680 KB
testcase_39 AC 629 ms
20,680 KB
testcase_40 AC 630 ms
20,680 KB
testcase_41 AC 496 ms
16,848 KB
testcase_42 AC 625 ms
20,680 KB
testcase_43 AC 524 ms
18,996 KB
testcase_44 AC 626 ms
20,680 KB
testcase_45 AC 428 ms
15,816 KB
testcase_46 AC 190 ms
9,808 KB
testcase_47 AC 620 ms
20,680 KB
testcase_48 AC 444 ms
20,680 KB
testcase_49 AC 793 ms
20,680 KB
testcase_50 AC 875 ms
20,680 KB
testcase_51 AC 813 ms
20,680 KB
testcase_52 AC 831 ms
20,680 KB
testcase_53 AC 83 ms
6,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 1000000000000000001


int main(){
	
	int n;
	cin>>n;
	
	vector<pair<int,int>> p;
	vector<int> a(n),b(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n){
		p.emplace_back(a[i],i);
		p.emplace_back(b[i],i);
		p.emplace_back((a[i]+b[i])/2,i);
	}
	
	sort(p.begin(),p.end());
	map<int,int> mp;
	int l = 0;
	int ans = Inf32;
	rep(i,p.size()){
		mp[p[i].second]++;
		while(mp.size()==n){
			if(mp[p[l].second]>1){
				mp[p[l].second]--;
				l++;
			}
			else break;
		}
		if(mp.size()==n)ans = min(ans,p[i].first-  p[l].first);
	}
	cout<<ans<<endl;
	
	return 0;
}
0