Submission #8164834


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, k; cin >> n >> k;
	vector<Int> a(n), f(n);
	for(auto &i:a) cin >> i;
	for(auto &i:f) cin >> i;
	sort(a.begin(), a.end());
	sort(f.rbegin(), f.rend());
	Int l = -1, r = 1'000'000'000'000;
	while(l + 1 < r){
		Int m = (l + r) / 2;
		Int t = 0;
		for(Int i=0; i<n; ++i){
			t += max<Int>((a[i] * f[i] - m + f[i] - 1) / f[i], 0);
		}
		if(t <= k) r = m;
		else l = m;
//		cout << m << " " << t << "\n";
	}
	cout << r << "\n";
}

Submission Info

Submission Time
Task E - Gluttony
User Power730
Language C++14 (GCC 5.4.1)
Score 500
Code Size 584 Byte
Status AC
Exec Time 148 ms
Memory 3328 KB

Judge Result

Set Name Sample Subtask1
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 38
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, sample_03.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt
Case Name Status Exec Time Memory
sample_01.txt AC 1 ms 256 KB
sample_02.txt AC 1 ms 256 KB
sample_03.txt AC 1 ms 256 KB
sub1_01.txt AC 127 ms 3328 KB
sub1_02.txt AC 4 ms 384 KB
sub1_03.txt AC 46 ms 1408 KB
sub1_04.txt AC 11 ms 512 KB
sub1_05.txt AC 67 ms 1664 KB
sub1_06.txt AC 86 ms 2176 KB
sub1_07.txt AC 3 ms 256 KB
sub1_08.txt AC 120 ms 2816 KB
sub1_09.txt AC 43 ms 1152 KB
sub1_10.txt AC 72 ms 1792 KB
sub1_11.txt AC 92 ms 2176 KB
sub1_12.txt AC 40 ms 1152 KB
sub1_13.txt AC 19 ms 640 KB
sub1_14.txt AC 65 ms 1664 KB
sub1_15.txt AC 52 ms 1408 KB
sub1_16.txt AC 83 ms 2048 KB
sub1_17.txt AC 67 ms 1664 KB
sub1_18.txt AC 127 ms 3328 KB
sub1_19.txt AC 127 ms 3328 KB
sub1_20.txt AC 126 ms 3328 KB
sub1_21.txt AC 127 ms 3328 KB
sub1_22.txt AC 126 ms 3328 KB
sub1_23.txt AC 127 ms 3328 KB
sub1_24.txt AC 124 ms 3328 KB
sub1_25.txt AC 127 ms 3328 KB
sub1_26.txt AC 148 ms 3328 KB
sub1_27.txt AC 148 ms 3328 KB
sub1_28.txt AC 148 ms 3328 KB
sub1_29.txt AC 148 ms 3328 KB
sub1_30.txt AC 148 ms 3328 KB
sub1_31.txt AC 148 ms 3328 KB
sub1_32.txt AC 148 ms 3328 KB
sub1_33.txt AC 148 ms 3328 KB
sub1_34.txt AC 3 ms 256 KB
sub1_35.txt AC 72 ms 1792 KB