Submission #907526

#TimeUsernameProblemLanguageResultExecution timeMemory
907526AlphaMale06Self Study (JOI22_ho_t2)C++14
0 / 100
430 ms10920 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define int long long


void solve(){
	int n, m;
	cin >> n >> m;
	int a[n], b[n];
	for(int i=0; i< n; i++)cin >> a[i];
	for(int i=0; i< n; i++)cin >> b[i];
	int l=1; int r=1e18+1;
	while(l<=r){
		int s=l+r>>1;
		int save=0;
		for(int i=0; i< n; i++){
			int mx=max(a[i], b[i]);
			int cnt=(s+mx-1)/mx;
			if(cnt<=m){
				save+=m-cnt;
			}
			else save-=(s-mx*m+b[i]-1)/b[i];
		}
		if(save>=0)l=s+1;
		else r=s-1;
	}
	cout << l-1 << '\n';
}


signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	solve();
}

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:23:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |   int s=l+r>>1;
      |         ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...