Submission #602288

# Submission time Handle Problem Language Result Execution time Memory
602288 2022-07-22T20:45:17 Z IvanJ Self Study (JOI22_ho_t2) C++17
0 / 100
1 ms 308 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn = 3e5 + 5;

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

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

int main() {
	scanf("%d%d", &n, &m);
	for(int i = 0;i < n;i++) scanf("%d", A + i);
	for(int i = 0;i < n;i++) scanf("%d", B + i);
	
	ll lo = 0, hi = 100, 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;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  scanf("%d%d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:24:32: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  for(int i = 0;i < n;i++) scanf("%d", A + i);
      |                           ~~~~~^~~~~~~~~~~~~
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("%d", B + i);
      |                           ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 308 KB Output isn't correct
2 Halted 0 ms 0 KB -