제출 #602294

#제출 시각아이디문제언어결과실행 시간메모리
602294IvanJSelf Study (JOI22_ho_t2)C++17
0 / 100
299 ms5120 KiB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 3e5 + 5;

int n;
ll m;
ll A[maxn], B[maxn];

int check(ll x) {
	ll ret = 0;
	for(int i = 0;i < n;i++) {
		ll a = max(A[i], B[i]) * m;
		if(x > a) ret -= (x - a + B[i] - 1) / B[i];
		else ret += (a - x) / max(A[i], B[i]);
	}
	return ret >= 0;
}

int main() {
	scanf("%d%lld", &n, &m);
	for(int i = 0;i < n;i++) scanf("%lld", A + i);
	for(int i = 0;i < n;i++) scanf("%lld", B + i);
	
	ll lo = 0, hi = 1e18, ans = -1;
	while(lo <= hi) {
		ll mid = (lo + hi) / 2;
		if(check(mid)) 
			ans = mid, lo = mid + 1;
		else hi = mid - 1;
	}
	printf("%lld\n", ans);
	return 0;
}

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

Main.cpp: In function 'int main()':
Main.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%d%lld", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
Main.cpp:25:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  for(int i = 0;i < n;i++) scanf("%lld", A + i);
      |                           ~~~~~^~~~~~~~~~~~~~~
Main.cpp:26:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  for(int i = 0;i < n;i++) scanf("%lld", B + i);
      |                           ~~~~~^~~~~~~~~~~~~~~
#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...