답안 #602291

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
602291 2022-07-22T20:48:27 Z IvanJ Self Study (JOI22_ho_t2) C++17
0 / 100
299 ms 8396 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 = 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;
}

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);
      |                           ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 162 ms 8388 KB Output is correct
12 Correct 163 ms 8396 KB Output is correct
13 Correct 163 ms 6452 KB Output is correct
14 Incorrect 299 ms 6436 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 304 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 83 ms 4372 KB Output is correct
10 Correct 56 ms 2940 KB Output is correct
11 Correct 42 ms 2328 KB Output is correct
12 Correct 34 ms 1868 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 5 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 162 ms 8388 KB Output is correct
12 Correct 163 ms 8396 KB Output is correct
13 Correct 163 ms 6452 KB Output is correct
14 Incorrect 299 ms 6436 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 304 KB Output is correct
7 Correct 0 ms 308 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 83 ms 4372 KB Output is correct
10 Correct 56 ms 2940 KB Output is correct
11 Correct 42 ms 2328 KB Output is correct
12 Correct 34 ms 1868 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Incorrect 5 ms 340 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 0 ms 304 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 3 ms 340 KB Output is correct
11 Correct 162 ms 8388 KB Output is correct
12 Correct 163 ms 8396 KB Output is correct
13 Correct 163 ms 6452 KB Output is correct
14 Incorrect 299 ms 6436 KB Output isn't correct
15 Halted 0 ms 0 KB -