結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー publflpublfl
提出日時 2021-01-22 22:25:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 423 ms / 2,000 ms
コード長 2,317 bytes
コンパイル時間 599 ms
コンパイル使用メモリ 56,604 KB
実行使用メモリ 32,860 KB
最終ジャッジ日時 2023-08-27 20:08:34
合計ジャッジ時間 16,346 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 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,376 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 1 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 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 6 ms
4,376 KB
testcase_22 AC 12 ms
4,380 KB
testcase_23 AC 18 ms
4,380 KB
testcase_24 AC 18 ms
4,376 KB
testcase_25 AC 19 ms
4,380 KB
testcase_26 AC 22 ms
4,376 KB
testcase_27 AC 13 ms
4,380 KB
testcase_28 AC 145 ms
17,712 KB
testcase_29 AC 133 ms
10,036 KB
testcase_30 AC 120 ms
10,476 KB
testcase_31 AC 132 ms
17,352 KB
testcase_32 AC 166 ms
17,312 KB
testcase_33 AC 105 ms
9,800 KB
testcase_34 AC 149 ms
17,292 KB
testcase_35 AC 208 ms
17,828 KB
testcase_36 AC 287 ms
21,956 KB
testcase_37 AC 62 ms
6,860 KB
testcase_38 AC 150 ms
12,492 KB
testcase_39 AC 95 ms
9,508 KB
testcase_40 AC 110 ms
10,920 KB
testcase_41 AC 176 ms
11,780 KB
testcase_42 AC 273 ms
20,948 KB
testcase_43 AC 174 ms
16,884 KB
testcase_44 AC 204 ms
18,752 KB
testcase_45 AC 167 ms
13,488 KB
testcase_46 AC 175 ms
18,588 KB
testcase_47 AC 104 ms
9,880 KB
testcase_48 AC 242 ms
30,212 KB
testcase_49 AC 169 ms
30,144 KB
testcase_50 AC 262 ms
30,060 KB
testcase_51 AC 224 ms
30,248 KB
testcase_52 AC 178 ms
30,644 KB
testcase_53 AC 398 ms
31,480 KB
testcase_54 AC 389 ms
30,188 KB
testcase_55 AC 423 ms
30,864 KB
testcase_56 AC 397 ms
29,944 KB
testcase_57 AC 263 ms
32,860 KB
testcase_58 AC 126 ms
31,280 KB
testcase_59 AC 128 ms
31,288 KB
testcase_60 AC 119 ms
30,624 KB
testcase_61 AC 119 ms
31,164 KB
testcase_62 AC 119 ms
31,020 KB
testcase_63 AC 62 ms
31,520 KB
testcase_64 AC 62 ms
31,588 KB
testcase_65 AC 66 ms
31,200 KB
testcase_66 AC 65 ms
30,252 KB
testcase_67 AC 65 ms
30,256 KB
testcase_68 AC 2 ms
4,380 KB
testcase_69 AC 1 ms
4,376 KB
testcase_70 AC 1 ms
4,380 KB
testcase_71 AC 1 ms
4,376 KB
testcase_72 AC 1 ms
4,384 KB
testcase_73 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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(V1[i].value==0)
		{
			if(ans==0)
			{
				printf("%lld %lld ",V1[i].index1,V1[i].index2);
				printf("%lld %lld",V2[0].index1,V2[0].index2);
				return 0;
			}
			else continue;
		}
		
		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("%lld %lld ",V1[i].index1,V1[i].index2);
					printf("%lld %lld",V2[h].index1,V2[h].index2);
					return 0;
				}
				else if(V2[h].value<t) min = h+1;
				else max = h-1;
			}
		}
	}
}
0