답안 #529435

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
529435 2022-02-23T02:22:17 Z fhvirus Self Study (JOI22_ho_t2) C++17
0 / 100
479 ms 2656 KB
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll; typedef pair<int, int> pii;
#define pb emplace_back
#define AI(x) begin(x),end(x)
#define ff first
#define ss second
#ifdef OWO
#define debug(args...) LKJ("\033[0;32m[ " + string(#args) + " ]\033[0m", args)
template<class I> void LKJ(I&&x) { cerr << x << endl; }
template<class I, class...T> void LKJ(I&&x, T&&...t) { cerr << x << ", "; LKJ(t...); }
template<class I> void OI(I a, I b) { while (a < b) cerr << *a << " \n"[next(a) == b]; }
#else
#define debug(...) 0
#define OI(...) 0
#endif

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int N, M; cin >> N >> M;
	vector<int> A(N), B(N);
	for (int &i: A) cin >> i;
	for (int &i: B) cin >> i;

	ll ans = 0;
	for (ll l = (1ll << 60); l > 0; l >>= 1) {
		ll threshold = ans + l;
		debug(threshold);
		ll empty = (ll) N * M;
		for (int i = 0; i < N; ++i) {
			ll tmp = threshold;
			if (A[i] >= B[i]) {
				ll chooseA = (tmp + A[i] - 1) / A[i];
				chooseA = min(chooseA, (ll) M);
				tmp -= A[i] * chooseA;
				empty -= chooseA;
				debug(i, chooseA);
			}
			if (tmp > 0) {
				ll chooseB = (tmp + B[i] - 1) / B[i];
				debug(i, chooseB);
				empty -= chooseB;
			}
		}
		if (empty >= 0) ans = threshold;
	}
	cout << ans << '\n';

	return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:14:20: warning: statement has no effect [-Wunused-value]
   14 | #define debug(...) 0
      |                    ^
Main.cpp:29:3: note: in expansion of macro 'debug'
   29 |   debug(threshold);
      |   ^~~~~
Main.cpp:14:20: warning: statement has no effect [-Wunused-value]
   14 | #define debug(...) 0
      |                    ^
Main.cpp:38:5: note: in expansion of macro 'debug'
   38 |     debug(i, chooseA);
      |     ^~~~~
Main.cpp:14:20: warning: statement has no effect [-Wunused-value]
   14 | #define debug(...) 0
      |                    ^
Main.cpp:42:5: note: in expansion of macro 'debug'
   42 |     debug(i, chooseB);
      |     ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 201 ms 2656 KB Output is correct
12 Correct 201 ms 2652 KB Output is correct
13 Correct 151 ms 2636 KB Output is correct
14 Incorrect 479 ms 2656 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 120 ms 1484 KB Output is correct
10 Correct 77 ms 1100 KB Output is correct
11 Correct 60 ms 896 KB Output is correct
12 Correct 48 ms 716 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Incorrect 9 ms 356 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 201 ms 2656 KB Output is correct
12 Correct 201 ms 2652 KB Output is correct
13 Correct 151 ms 2636 KB Output is correct
14 Incorrect 479 ms 2656 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 120 ms 1484 KB Output is correct
10 Correct 77 ms 1100 KB Output is correct
11 Correct 60 ms 896 KB Output is correct
12 Correct 48 ms 716 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 0 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 0 ms 204 KB Output is correct
18 Incorrect 9 ms 356 KB Output isn't correct
19 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 3 ms 332 KB Output is correct
11 Correct 201 ms 2656 KB Output is correct
12 Correct 201 ms 2652 KB Output is correct
13 Correct 151 ms 2636 KB Output is correct
14 Incorrect 479 ms 2656 KB Output isn't correct
15 Halted 0 ms 0 KB -