結果

問題 No.1361 [Zelkova 4th Tune *] QUADRUPLE-SEQUENCEの詩
ユーザー HIR180HIR180
提出日時 2021-01-22 23:31:25
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,738 ms / 2,000 ms
コード長 3,619 bytes
コンパイル時間 3,601 ms
コンパイル使用メモリ 249,272 KB
実行使用メモリ 23,928 KB
最終ジャッジ日時 2023-08-27 22:59:27
合計ジャッジ時間 45,158 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 5 ms
4,380 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 6 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 4 ms
4,376 KB
testcase_17 AC 6 ms
4,376 KB
testcase_18 AC 79 ms
4,380 KB
testcase_19 AC 32 ms
4,376 KB
testcase_20 AC 86 ms
4,376 KB
testcase_21 AC 22 ms
4,380 KB
testcase_22 AC 37 ms
4,376 KB
testcase_23 AC 59 ms
4,376 KB
testcase_24 AC 48 ms
4,376 KB
testcase_25 AC 55 ms
4,376 KB
testcase_26 AC 70 ms
4,380 KB
testcase_27 AC 46 ms
4,376 KB
testcase_28 AC 579 ms
13,340 KB
testcase_29 AC 513 ms
7,976 KB
testcase_30 AC 463 ms
8,052 KB
testcase_31 AC 596 ms
13,212 KB
testcase_32 AC 435 ms
12,656 KB
testcase_33 AC 415 ms
8,044 KB
testcase_34 AC 646 ms
14,480 KB
testcase_35 AC 817 ms
12,408 KB
testcase_36 AC 1,115 ms
16,384 KB
testcase_37 AC 217 ms
5,988 KB
testcase_38 AC 651 ms
9,264 KB
testcase_39 AC 371 ms
7,840 KB
testcase_40 AC 468 ms
7,984 KB
testcase_41 AC 611 ms
9,656 KB
testcase_42 AC 1,151 ms
15,304 KB
testcase_43 AC 616 ms
11,760 KB
testcase_44 AC 849 ms
13,364 KB
testcase_45 AC 732 ms
10,264 KB
testcase_46 AC 582 ms
12,712 KB
testcase_47 AC 334 ms
7,204 KB
testcase_48 AC 1,161 ms
22,760 KB
testcase_49 AC 1,007 ms
22,028 KB
testcase_50 AC 1,220 ms
23,652 KB
testcase_51 AC 1,149 ms
23,516 KB
testcase_52 AC 939 ms
21,892 KB
testcase_53 AC 1,623 ms
22,224 KB
testcase_54 AC 1,607 ms
23,008 KB
testcase_55 AC 1,738 ms
22,896 KB
testcase_56 AC 1,620 ms
22,932 KB
testcase_57 AC 1,278 ms
23,928 KB
testcase_58 AC 1,128 ms
22,368 KB
testcase_59 AC 1,137 ms
21,992 KB
testcase_60 AC 975 ms
22,316 KB
testcase_61 AC 990 ms
22,980 KB
testcase_62 AC 978 ms
22,480 KB
testcase_63 AC 80 ms
21,824 KB
testcase_64 AC 82 ms
23,780 KB
testcase_65 AC 82 ms
23,460 KB
testcase_66 AC 80 ms
22,448 KB
testcase_67 AC 80 ms
23,648 KB
testcase_68 AC 2 ms
4,380 KB
testcase_69 AC 2 ms
4,376 KB
testcase_70 AC 1 ms
4,380 KB
testcase_71 AC 2 ms
4,376 KB
testcase_72 AC 1 ms
4,376 KB
testcase_73 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//Let's join Kaede Takagaki Fan Club !!
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#define int long long
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define a first
#define b second
#define fi first
#define sc second
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define all(x) x.begin(),x.end()
#define si(x) int(x.size())

#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif

template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b;return true;}else return false;}
template<class t,class u> bool chmin(t&a,u b){if(b<a){a=b;return true;}else return false;}

template<class t> using vc=vector<t>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.fi<<","<<p.sc<<"}";
}

template<class t> ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

template<class T>
void g(T &a){
	cin >> a;
}
template<class T>
void o(const T &a,bool space=false){
	cout << a << (space?' ':'\n');
}
//ios::sync_with_stdio(false);
const ll mod = 1000000007;//998244353
//mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
template<class T>
void add(T&a,T b){
	a+=b;
	if(a >= mod) a-=mod;
}
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll divv(ll a, ll b) { // floored division
	if (b < 0) a *= -1, b *= -1;
	if (a >= 0) return a / b;
	return -((-a + b - 1) / b);
}

int n[4];
vc<int>a[4];
ll cnt;
vc<pair<ll,P>>v[2];

void solve(){
	rep(i, 4) cin >> n[i];
	cin >> cnt;
	rep(i, 4){
	    a[i].resize(n[i]);
		rep(j, n[i]) cin >> a[i][j];
	}
	rep(i, 2){
		for(auto at:a[i*2]){
			for(auto at2:a[i*2+1]){
				v[i].pb(mp(1LL*at*at2, mp(at, at2)));
			}
		}
		SORT(v[i]);
	}
	ll lb = -1e18, ub = 1e18;
	//(lb, ub]
	while(ub-lb > 1){
		ll mid = (lb+ub)/2, C = 0;
		for(auto att:v[0]){
			ll at = att.a; 
			ll lv, uv;
			if(at == 0){
				if(mid < 0) continue;
				lv = -1e18, uv = 1e18;
			}
			else if(at > 0){
				lv = -1e18;
				uv = divv(mid, at);
			}
			else{
				uv = 1e18;
				lv = divv(mid, at);
				if(mid%at != 0) lv ++;
			}
			ll X = v[1].size(), Y = 0;
			if(uv != 1e18) X = POSU(v[1], mp(uv+1, mp(-INF, -INF)));
			if(lv != -1e18) Y = POSL(v[1], mp(lv, mp(-INF, -INF)));
			C += X - Y;
		}
		if(C >= cnt) ub = mid;
		else lb = mid;
	}
	for(auto att:v[0]){
		ll at = att.a;
		if(at == 0){
		    if(ub) continue;
		    cout << ub << endl;
		    cout << att.b.a << " " << att.b.b << " ";
			cout << v[1][0].b.a << " " << v[1][0].b.b << endl;
			return;
		}
		if(ub%at != 0) continue;
		int x = POSL(v[1], mp(ub/at, mp(-INF, -INF)));
		if(x < v[1].size() && v[1][x].a == ub/at){
		    cout<<ub<<endl;
			cout << att.b.a << " " << att.b.b << " ";
			cout << v[1][x].b.a << " " << v[1][x].b.b << endl;
			return;
		}
	}
	assert(false);
}
signed main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout<<fixed<<setprecision(20);
	int t; t = 1; //cin >> t;
	while(t--) solve();
}
0