結果

問題 No.2248 max(C)-min(C)
ユーザー kotatsugamekotatsugame
提出日時 2023-03-17 22:02:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 635 ms / 3,000 ms
コード長 630 bytes
コンパイル時間 1,689 ms
コンパイル使用メモリ 73,524 KB
実行使用メモリ 16,368 KB
最終ジャッジ日時 2023-10-18 14:46:09
合計ジャッジ時間 13,730 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,672 KB
testcase_01 AC 3 ms
5,672 KB
testcase_02 AC 2 ms
5,672 KB
testcase_03 AC 3 ms
5,716 KB
testcase_04 AC 3 ms
5,704 KB
testcase_05 AC 3 ms
5,692 KB
testcase_06 AC 4 ms
5,756 KB
testcase_07 AC 4 ms
5,776 KB
testcase_08 AC 4 ms
5,776 KB
testcase_09 AC 4 ms
5,776 KB
testcase_10 AC 3 ms
5,692 KB
testcase_11 AC 4 ms
5,776 KB
testcase_12 AC 3 ms
5,724 KB
testcase_13 AC 4 ms
5,744 KB
testcase_14 AC 4 ms
5,776 KB
testcase_15 AC 4 ms
5,776 KB
testcase_16 AC 3 ms
5,712 KB
testcase_17 AC 4 ms
5,764 KB
testcase_18 AC 243 ms
14,856 KB
testcase_19 AC 26 ms
6,772 KB
testcase_20 AC 282 ms
16,340 KB
testcase_21 AC 267 ms
15,744 KB
testcase_22 AC 172 ms
12,384 KB
testcase_23 AC 103 ms
9,980 KB
testcase_24 AC 39 ms
7,372 KB
testcase_25 AC 246 ms
15,256 KB
testcase_26 AC 218 ms
14,032 KB
testcase_27 AC 250 ms
15,056 KB
testcase_28 AC 21 ms
6,576 KB
testcase_29 AC 230 ms
14,380 KB
testcase_30 AC 82 ms
9,104 KB
testcase_31 AC 283 ms
16,352 KB
testcase_32 AC 45 ms
7,612 KB
testcase_33 AC 75 ms
8,828 KB
testcase_34 AC 293 ms
16,368 KB
testcase_35 AC 284 ms
16,368 KB
testcase_36 AC 287 ms
16,360 KB
testcase_37 AC 131 ms
10,928 KB
testcase_38 AC 473 ms
16,368 KB
testcase_39 AC 496 ms
16,368 KB
testcase_40 AC 481 ms
16,368 KB
testcase_41 AC 385 ms
14,660 KB
testcase_42 AC 488 ms
16,368 KB
testcase_43 AC 417 ms
15,008 KB
testcase_44 AC 486 ms
16,368 KB
testcase_45 AC 349 ms
13,684 KB
testcase_46 AC 143 ms
9,828 KB
testcase_47 AC 490 ms
16,368 KB
testcase_48 AC 263 ms
16,368 KB
testcase_49 AC 610 ms
16,368 KB
testcase_50 AC 614 ms
16,368 KB
testcase_51 AC 635 ms
16,368 KB
testcase_52 AC 609 ms
16,368 KB
testcase_53 AC 60 ms
7,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
using namespace std;
int N;
int A[2<<17][3];
int id[2<<17];
int main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>A[i][0];
	for(int i=0;i<N;i++)cin>>A[i][1];
	set<pair<int,int> >S;
	for(int i=0;i<N;i++)
	{
		int a=A[i][0],b=A[i][1];
		if(a>b)swap(a,b);
		A[i][0]=a;
		A[i][1]=(a+b)/2;
		A[i][2]=b;
		S.insert(make_pair(a,i));
	}
	int ans=S.rbegin()->first-S.begin()->first;
	while(true)
	{
		pair<int,int>p=*S.begin();
		S.erase(S.begin());
		int i=p.second;
		if(id[i]==2)break;
		id[i]++;
		S.insert(make_pair(A[i][id[i]],i));
		ans=min(ans,S.rbegin()->first-S.begin()->first);
	}
	cout<<ans<<endl;
}
0