結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー publflpublfl
提出日時 2021-01-22 22:22:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,116 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 56,720 KB
実行使用メモリ 32,748 KB
最終ジャッジ日時 2023-08-27 20:00:06
合計ジャッジ時間 20,212 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,388 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,384 KB
testcase_16 AC 3 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 19 ms
4,376 KB
testcase_19 AC 9 ms
4,380 KB
testcase_20 AC 21 ms
4,376 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 13 ms
4,376 KB
testcase_23 AC 18 ms
4,380 KB
testcase_24 AC 18 ms
4,376 KB
testcase_25 AC 19 ms
4,376 KB
testcase_26 AC 21 ms
4,380 KB
testcase_27 AC 14 ms
4,376 KB
testcase_28 RE -
testcase_29 AC 139 ms
10,652 KB
testcase_30 AC 118 ms
9,916 KB
testcase_31 AC 138 ms
17,932 KB
testcase_32 AC 171 ms
17,476 KB
testcase_33 AC 106 ms
10,036 KB
testcase_34 AC 161 ms
17,156 KB
testcase_35 AC 205 ms
16,968 KB
testcase_36 AC 320 ms
22,460 KB
testcase_37 AC 63 ms
7,044 KB
testcase_38 AC 155 ms
13,820 KB
testcase_39 AC 94 ms
9,620 KB
testcase_40 AC 113 ms
10,140 KB
testcase_41 AC 184 ms
12,088 KB
testcase_42 AC 291 ms
21,488 KB
testcase_43 AC 181 ms
16,424 KB
testcase_44 AC 209 ms
18,188 KB
testcase_45 AC 168 ms
12,764 KB
testcase_46 AC 178 ms
16,924 KB
testcase_47 AC 104 ms
9,580 KB
testcase_48 AC 272 ms
30,104 KB
testcase_49 AC 203 ms
31,376 KB
testcase_50 AC 302 ms
31,836 KB
testcase_51 AC 262 ms
30,688 KB
testcase_52 AC 208 ms
31,568 KB
testcase_53 AC 437 ms
29,812 KB
testcase_54 AC 429 ms
32,748 KB
testcase_55 AC 463 ms
31,712 KB
testcase_56 AC 425 ms
31,064 KB
testcase_57 AC 276 ms
31,420 KB
testcase_58 AC 139 ms
30,072 KB
testcase_59 AC 136 ms
31,256 KB
testcase_60 AC 126 ms
30,212 KB
testcase_61 AC 128 ms
30,148 KB
testcase_62 AC 129 ms
31,688 KB
testcase_63 RE -
testcase_64 RE -
testcase_65 RE -
testcase_66 RE -
testcase_67 RE -
testcase_68 RE -
testcase_69 RE -
testcase_70 AC 1 ms
4,380 KB
testcase_71 AC 1 ms
4,380 KB
testcase_72 AC 2 ms
4,380 KB
testcase_73 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <vector>

struct str{
	long long int value;
	long long int index1;
	long long int index2;
};
std::vector<str> V1,V2;
bool operator<(str a, str b)
{
	return a.value<b.value;
}


int x[610],y[610];
long long int MIN = -1, MAX = 1;
int main()
{
	for(int i=1;i<=18;i++) MIN*=10, MAX*=10;
	int a,b,c,d;
	long long int e;
	scanf("%d%d%d%d%lld",&a,&b,&c,&d,&e);
	for(int i=1;i<=a;i++) scanf("%d",&x[i]);
	for(int i=1;i<=b;i++) scanf("%d",&y[i]);
	for(int i=1;i<=a;i++) for(int j=1;j<=b;j++) V1.push_back({x[i]*y[j],x[i],y[j]});
	
	for(int i=1;i<=c;i++) scanf("%d",&x[i]);
	for(int i=1;i<=d;i++) scanf("%d",&y[i]);
	for(int i=1;i<=c;i++) for(int j=1;j<=d;j++) V2.push_back({x[i]*y[j],x[i],y[j]});
	
	std::sort(V1.begin(),V1.end());
	std::sort(V2.begin(),V2.end());
	
	long long int min = MIN, max = MAX;
	long long int ans = MAX;
	while(min<=max)
	{
		long long int h = (min+max)/2;
		//count val<=h
		
		int ind = 0;
		int control = 0;
		long long int sum = 0;
		for(int i=0;i<V1.size();i++)
		{
			if(V1[i].value<=0)
			{
				if(V1[i].value*V2[0].value<=h) sum += V2.size();
				else if(V1[i].value*V2.back().value>h);
				else
				{
					while(ind>=0&&V1[i].value*V2[ind].value<=h) ind--;
					while(ind<V2.size()&&V1[i].value*V2[ind].value>h) ind++;
					sum += (V2.size()-ind);
				}
			}
			else
			{
				if(V1[i].value*V2[0].value>h);
				else if(V1[i].value*V2.back().value<=h) sum += V2.size();
				else
				{
					while(ind<V2.size()&&V1[i].value*V2[ind].value<=h) ind++;
					while(ind>=0&&V1[i].value*V2[ind].value>h) ind--;
					sum += (ind+1);
				}
			}
		}
		
		if(sum>=e)
		{
			ans = h;
			max = h-1;
		}
		else min = h+1;
	}
	printf("%lld\n",ans);
	for(int i=0;i<V1.size();i++)
	{
		if(ans%(V1[i].value)==0)
		{
			long long int t = (ans)/(V1[i].value);
			int min = 0, max = V2.size()-1;
			while(min<=max)
			{
				int h = (min+max)/2;
				if(V2[h].value==t)
				{
					printf("%d %d ",V1[i].index1,V1[i].index2);
					printf("%d %d",V2[h].index1,V2[h].index2);
					return 0;
				}
				else if(V2[h].value<t) min = h+1;
				else max = h-1;
			}
		}
	}
}
0