結果

問題 No.2248 max(C)-min(C)
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-07-15 04:35:14
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 306 ms / 3,000 ms
コード長 939 bytes
コンパイル時間 5,946 ms
コンパイル使用メモリ 311,568 KB
実行使用メモリ 18,016 KB
最終ジャッジ日時 2023-10-14 19:06:32
合計ジャッジ時間 14,043 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 3 ms
4,352 KB
testcase_07 AC 3 ms
4,352 KB
testcase_08 AC 3 ms
4,352 KB
testcase_09 AC 3 ms
4,352 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 3 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 3 ms
4,352 KB
testcase_15 AC 3 ms
4,352 KB
testcase_16 AC 2 ms
4,476 KB
testcase_17 AC 3 ms
4,352 KB
testcase_18 AC 152 ms
15,952 KB
testcase_19 AC 21 ms
4,928 KB
testcase_20 AC 172 ms
17,800 KB
testcase_21 AC 164 ms
17,280 KB
testcase_22 AC 116 ms
13,508 KB
testcase_23 AC 75 ms
9,416 KB
testcase_24 AC 30 ms
5,904 KB
testcase_25 AC 157 ms
16,504 KB
testcase_26 AC 140 ms
15,428 KB
testcase_27 AC 155 ms
16,380 KB
testcase_28 AC 17 ms
4,840 KB
testcase_29 AC 144 ms
15,604 KB
testcase_30 AC 60 ms
8,344 KB
testcase_31 AC 174 ms
18,016 KB
testcase_32 AC 35 ms
6,204 KB
testcase_33 AC 56 ms
7,832 KB
testcase_34 AC 173 ms
17,800 KB
testcase_35 AC 173 ms
17,792 KB
testcase_36 AC 174 ms
18,004 KB
testcase_37 AC 91 ms
10,760 KB
testcase_38 AC 151 ms
18,004 KB
testcase_39 AC 150 ms
17,852 KB
testcase_40 AC 151 ms
17,976 KB
testcase_41 AC 129 ms
15,832 KB
testcase_42 AC 151 ms
17,852 KB
testcase_43 AC 134 ms
16,320 KB
testcase_44 AC 151 ms
17,800 KB
testcase_45 AC 118 ms
14,936 KB
testcase_46 AC 64 ms
9,304 KB
testcase_47 AC 151 ms
17,796 KB
testcase_48 AC 173 ms
17,884 KB
testcase_49 AC 305 ms
17,884 KB
testcase_50 AC 305 ms
17,908 KB
testcase_51 AC 304 ms
17,944 KB
testcase_52 AC 306 ms
17,780 KB
testcase_53 AC 40 ms
5,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define db double
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
	int n;cin>>n;
	vc<int>a(n),b(n); rep(i,n)cin>>a[i]; rep(i,n)cin>>b[i];
	rep(i,n)if(a[i]>b[i])swap(a[i],b[i]);
	vc v(n,vc<int>(3));
	rep(i,n){
		v[i][0]=b[i];
		v[i][1]=(a[i]+b[i])/2;
		v[i][2]=a[i];
	}
	int mn=1e9;
	pque<pp>q;
	rep(i,n)q.push({v[i][0],i});
	rep(i,n)mn=min(mn,v[i][0]);
	int ans=2e9;
	vc<int>now(n,0);
	while(q.size()){
		auto [a,t]=q.top(); q.pop();
		ans=min(ans,a-mn);
		if(now[t]==2)break;
		int x=v[t][now[t]+1]; now[t]++;
		q.push({x,t});
		mn=min(mn,x);
	}
	cout<<ans;
}
	
0