제출 #532661

#제출 시각아이디문제언어결과실행 시간메모리
532661victor_gaoSelf Study (JOI22_ho_t2)C++17
100 / 100
283 ms10796 KiB
//#pragma GCC optimize("Ofast,unroll-loops,O3")
//#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//#pragma pack(1)
#define fast ios::sync_with_stdio(0); cin.tie(0);
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define N 300015
using namespace std;
//using namespace __gnu_pbds;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset;
//typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set;
int a[N],b[N],n,m;
bool check(unsigned long long val){
	int cnt=0;
	for (int i=1;i<=n;i++){
		if (a[i]>b[i]){
			if (a[i]*m<val){
				cnt+=m;
				unsigned long long newval=val-a[i]*m;
				cnt+=(newval/b[i]+(newval%b[i]>0));		
			}
			else cnt+=(val/a[i]+(val%a[i]>0));
		}
		else {
			cnt+=(val/b[i]+(val%b[i]>0));
		}
		if (cnt>m*n) return 0;
	}
	return cnt<=m*n;
}
signed main(){
	fast
	cin>>n>>m;
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=1;i<=n;i++) cin>>b[i];
	unsigned long long l=0,r=5e18;
	while (l<r){
		int mid=(l+r)>>1;
		if (check(mid)) l=mid+1;
		else r=mid;
	}
	cout<<l-1<<'\n';
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'bool check(long long unsigned int)':
Main.cpp:22:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'long long unsigned int' [-Wsign-compare]
   22 |    if (a[i]*m<val){
      |        ~~~~~~^~~~
#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...