답안 #703252

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703252 2023-02-26T18:27:30 Z MilosMilutinovic Self Study (JOI22_ho_t2) C++14
100 / 100
252 ms 9104 KB
/**
 *    author:  wxhtzdy
 *    created: 26.02.2023 19:18:55
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);  
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> b[i];           
    if (a[i] < b[i]) {
      a[i] = b[i];
    }
  }
  auto Solve = [&](long long x) {
    long long f = 0;
    for (int i = 0; i < n; i++) {
      if (m * 1LL * a[i] >= x) {
        long long take = (x + a[i] - 1) / a[i];
        f += m - take;
      }
    }         
    for (int i = 0; i < n; i++) {
      if (m * 1LL * a[i] < x) {
        long long need = (x - m * 1LL * a[i] + b[i] - 1) / b[i];
        f -= need;
        if (f < 0) {
          return false;
        }
      }
    }
    return f >= 0;
  };
  long long low = 0, high = 1e18, ans = 0;
  while (low <= high) {
    long long mid = low + high >> 1;
    if (Solve(mid)) {
      ans = mid;
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  cout << ans << '\n';                  
  return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:46:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   46 |     long long mid = low + high >> 1;
      |                     ~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 110 ms 2648 KB Output is correct
12 Correct 101 ms 2644 KB Output is correct
13 Correct 81 ms 2644 KB Output is correct
14 Correct 84 ms 2636 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 46 ms 3796 KB Output is correct
17 Correct 104 ms 9104 KB Output is correct
18 Correct 105 ms 8376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 46 ms 3796 KB Output is correct
3 Correct 104 ms 9104 KB Output is correct
4 Correct 105 ms 8376 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 55 ms 1484 KB Output is correct
14 Correct 37 ms 1108 KB Output is correct
15 Correct 27 ms 880 KB Output is correct
16 Correct 23 ms 724 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 3 ms 456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 110 ms 2648 KB Output is correct
12 Correct 101 ms 2644 KB Output is correct
13 Correct 81 ms 2644 KB Output is correct
14 Correct 84 ms 2636 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 55 ms 1484 KB Output is correct
24 Correct 37 ms 1108 KB Output is correct
25 Correct 27 ms 880 KB Output is correct
26 Correct 23 ms 724 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 3 ms 456 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 46 ms 3796 KB Output is correct
36 Correct 104 ms 9104 KB Output is correct
37 Correct 105 ms 8376 KB Output is correct
38 Correct 1 ms 212 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 0 ms 212 KB Output is correct
42 Correct 0 ms 212 KB Output is correct
43 Correct 0 ms 320 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 3 ms 460 KB Output is correct
46 Correct 4 ms 468 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 21 ms 1724 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 324 KB Output is correct
51 Correct 3 ms 436 KB Output is correct
52 Correct 0 ms 212 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 320 KB Output is correct
55 Correct 57 ms 4332 KB Output is correct
56 Correct 28 ms 2380 KB Output is correct
57 Correct 29 ms 2376 KB Output is correct
# 결과 실행 시간 메모리 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 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 55 ms 1484 KB Output is correct
10 Correct 37 ms 1108 KB Output is correct
11 Correct 27 ms 880 KB Output is correct
12 Correct 23 ms 724 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 3 ms 456 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 46 ms 3796 KB Output is correct
22 Correct 104 ms 9104 KB Output is correct
23 Correct 105 ms 8376 KB Output is correct
24 Correct 32 ms 1580 KB Output is correct
25 Correct 80 ms 3908 KB Output is correct
26 Correct 14 ms 1108 KB Output is correct
27 Correct 109 ms 8396 KB Output is correct
28 Correct 117 ms 8512 KB Output is correct
29 Correct 115 ms 8392 KB Output is correct
30 Correct 139 ms 8408 KB Output is correct
31 Correct 219 ms 8400 KB Output is correct
32 Correct 82 ms 3832 KB Output is correct
33 Correct 252 ms 9036 KB Output is correct
34 Correct 83 ms 3808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 110 ms 2648 KB Output is correct
12 Correct 101 ms 2644 KB Output is correct
13 Correct 81 ms 2644 KB Output is correct
14 Correct 84 ms 2636 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 55 ms 1484 KB Output is correct
24 Correct 37 ms 1108 KB Output is correct
25 Correct 27 ms 880 KB Output is correct
26 Correct 23 ms 724 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 0 ms 212 KB Output is correct
31 Correct 0 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 3 ms 456 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 0 ms 320 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 3 ms 460 KB Output is correct
42 Correct 4 ms 468 KB Output is correct
43 Correct 1 ms 332 KB Output is correct
44 Correct 21 ms 1724 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 324 KB Output is correct
47 Correct 3 ms 436 KB Output is correct
48 Correct 0 ms 212 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 320 KB Output is correct
51 Correct 57 ms 4332 KB Output is correct
52 Correct 28 ms 2380 KB Output is correct
53 Correct 29 ms 2376 KB Output is correct
54 Correct 32 ms 1580 KB Output is correct
55 Correct 80 ms 3908 KB Output is correct
56 Correct 14 ms 1108 KB Output is correct
57 Correct 109 ms 8396 KB Output is correct
58 Correct 117 ms 8512 KB Output is correct
59 Correct 115 ms 8392 KB Output is correct
60 Correct 139 ms 8408 KB Output is correct
61 Correct 219 ms 8400 KB Output is correct
62 Correct 82 ms 3832 KB Output is correct
63 Correct 252 ms 9036 KB Output is correct
64 Correct 83 ms 3808 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 46 ms 3796 KB Output is correct
67 Correct 104 ms 9104 KB Output is correct
68 Correct 105 ms 8376 KB Output is correct
69 Correct 23 ms 1108 KB Output is correct
70 Correct 7 ms 468 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 33 ms 1504 KB Output is correct
73 Correct 7 ms 468 KB Output is correct
74 Correct 1 ms 332 KB Output is correct
75 Correct 119 ms 8456 KB Output is correct
76 Correct 130 ms 8408 KB Output is correct
77 Correct 140 ms 8380 KB Output is correct
78 Correct 170 ms 8400 KB Output is correct
79 Correct 222 ms 8388 KB Output is correct
80 Correct 241 ms 8380 KB Output is correct
81 Correct 229 ms 6348 KB Output is correct
82 Correct 230 ms 6352 KB Output is correct