답안 #1110764

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1110764 2024-11-10T11:51:22 Z Flandre Self Study (JOI22_ho_t2) C++17
100 / 100
103 ms 11592 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;

// loal is the cutest girl

#define ll long long
#define int ll
#define ld long double
#define pow2(x) (x)*(x)
#define le left
#define ri right
#define fi first
#define se second
#define pb push_back
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
#define isvowel(x) (x) == 'a' || (x) == 'i' || (x) == 'u' || (x) == 'e' || (x) == 'o'
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

const ld EPS = 1e-9;
const ld PI = 3.141592653589793238462643383279502884197169399375105820974944;

const int maxn = 3e5+5;
int n, m;
int a[maxn];
int b[maxn];

bool solve(ll amo) {
  ll needed = 0;
  for (int i = 0; i < n; i++) {
    if (a[i]*m >= amo) {
      needed += (amo+a[i]-1)/a[i];
    } else {
      needed += m+(amo-a[i]*m+b[i]-1)/b[i];
    }
    if (needed > n*m) return false;
  }
  return true;
}

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  for (int i = 0; i < n; i++) {
    cin >> b[i];
    a[i] = max(a[i], b[i]);
  }

  ll l = 1, r = 1e18;

  while (l < r) {
    ll mid = (l+r+1)/2;
    if (solve(mid)) l = mid;
    else r = mid-1;
  }

  // solve(18);

  // for (int i = 0; ; i++) if (!solve(i)) {
  //   cout << i-1;
  //   return 0;
  // }

  cout << l << '\n';

  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 59 ms 5076 KB Output is correct
12 Correct 69 ms 4944 KB Output is correct
13 Correct 47 ms 5112 KB Output is correct
14 Correct 47 ms 5080 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 21 ms 6328 KB Output is correct
17 Correct 67 ms 11592 KB Output is correct
18 Correct 65 ms 10832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 21 ms 6328 KB Output is correct
3 Correct 67 ms 11592 KB Output is correct
4 Correct 65 ms 10832 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 39 ms 4688 KB Output is correct
14 Correct 23 ms 4708 KB Output is correct
15 Correct 18 ms 4688 KB Output is correct
16 Correct 15 ms 4700 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2384 KB Output is correct
23 Correct 2 ms 2640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 59 ms 5076 KB Output is correct
12 Correct 69 ms 4944 KB Output is correct
13 Correct 47 ms 5112 KB Output is correct
14 Correct 47 ms 5080 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 39 ms 4688 KB Output is correct
24 Correct 23 ms 4708 KB Output is correct
25 Correct 18 ms 4688 KB Output is correct
26 Correct 15 ms 4700 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 1 ms 2384 KB Output is correct
31 Correct 1 ms 2384 KB Output is correct
32 Correct 1 ms 2384 KB Output is correct
33 Correct 2 ms 2640 KB Output is correct
34 Correct 1 ms 2384 KB Output is correct
35 Correct 21 ms 6328 KB Output is correct
36 Correct 67 ms 11592 KB Output is correct
37 Correct 65 ms 10832 KB Output is correct
38 Correct 1 ms 2384 KB Output is correct
39 Correct 1 ms 2384 KB Output is correct
40 Correct 1 ms 2384 KB Output is correct
41 Correct 1 ms 2384 KB Output is correct
42 Correct 1 ms 2384 KB Output is correct
43 Correct 1 ms 2384 KB Output is correct
44 Correct 1 ms 2552 KB Output is correct
45 Correct 2 ms 2640 KB Output is correct
46 Correct 4 ms 2640 KB Output is correct
47 Correct 2 ms 2436 KB Output is correct
48 Correct 12 ms 5712 KB Output is correct
49 Correct 1 ms 2384 KB Output is correct
50 Correct 1 ms 2384 KB Output is correct
51 Correct 3 ms 2640 KB Output is correct
52 Correct 1 ms 2552 KB Output is correct
53 Correct 1 ms 2552 KB Output is correct
54 Correct 1 ms 2512 KB Output is correct
55 Correct 35 ms 7504 KB Output is correct
56 Correct 20 ms 5968 KB Output is correct
57 Correct 17 ms 5964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 39 ms 4688 KB Output is correct
10 Correct 23 ms 4708 KB Output is correct
11 Correct 18 ms 4688 KB Output is correct
12 Correct 15 ms 4700 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 2 ms 2640 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 21 ms 6328 KB Output is correct
22 Correct 67 ms 11592 KB Output is correct
23 Correct 65 ms 10832 KB Output is correct
24 Correct 14 ms 5468 KB Output is correct
25 Correct 37 ms 7240 KB Output is correct
26 Correct 12 ms 5200 KB Output is correct
27 Correct 63 ms 10824 KB Output is correct
28 Correct 66 ms 10816 KB Output is correct
29 Correct 68 ms 10824 KB Output is correct
30 Correct 75 ms 10788 KB Output is correct
31 Correct 86 ms 10820 KB Output is correct
32 Correct 45 ms 6224 KB Output is correct
33 Correct 92 ms 11560 KB Output is correct
34 Correct 45 ms 6224 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 2 ms 2384 KB Output is correct
11 Correct 59 ms 5076 KB Output is correct
12 Correct 69 ms 4944 KB Output is correct
13 Correct 47 ms 5112 KB Output is correct
14 Correct 47 ms 5080 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 1 ms 2384 KB Output is correct
17 Correct 1 ms 2384 KB Output is correct
18 Correct 1 ms 2384 KB Output is correct
19 Correct 1 ms 2384 KB Output is correct
20 Correct 1 ms 2384 KB Output is correct
21 Correct 1 ms 2384 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 39 ms 4688 KB Output is correct
24 Correct 23 ms 4708 KB Output is correct
25 Correct 18 ms 4688 KB Output is correct
26 Correct 15 ms 4700 KB Output is correct
27 Correct 1 ms 2384 KB Output is correct
28 Correct 1 ms 2384 KB Output is correct
29 Correct 1 ms 2384 KB Output is correct
30 Correct 1 ms 2384 KB Output is correct
31 Correct 1 ms 2384 KB Output is correct
32 Correct 1 ms 2384 KB Output is correct
33 Correct 2 ms 2640 KB Output is correct
34 Correct 1 ms 2384 KB Output is correct
35 Correct 1 ms 2384 KB Output is correct
36 Correct 1 ms 2384 KB Output is correct
37 Correct 1 ms 2384 KB Output is correct
38 Correct 1 ms 2384 KB Output is correct
39 Correct 1 ms 2384 KB Output is correct
40 Correct 1 ms 2552 KB Output is correct
41 Correct 2 ms 2640 KB Output is correct
42 Correct 4 ms 2640 KB Output is correct
43 Correct 2 ms 2436 KB Output is correct
44 Correct 12 ms 5712 KB Output is correct
45 Correct 1 ms 2384 KB Output is correct
46 Correct 1 ms 2384 KB Output is correct
47 Correct 3 ms 2640 KB Output is correct
48 Correct 1 ms 2552 KB Output is correct
49 Correct 1 ms 2552 KB Output is correct
50 Correct 1 ms 2512 KB Output is correct
51 Correct 35 ms 7504 KB Output is correct
52 Correct 20 ms 5968 KB Output is correct
53 Correct 17 ms 5964 KB Output is correct
54 Correct 14 ms 5468 KB Output is correct
55 Correct 37 ms 7240 KB Output is correct
56 Correct 12 ms 5200 KB Output is correct
57 Correct 63 ms 10824 KB Output is correct
58 Correct 66 ms 10816 KB Output is correct
59 Correct 68 ms 10824 KB Output is correct
60 Correct 75 ms 10788 KB Output is correct
61 Correct 86 ms 10820 KB Output is correct
62 Correct 45 ms 6224 KB Output is correct
63 Correct 92 ms 11560 KB Output is correct
64 Correct 45 ms 6224 KB Output is correct
65 Correct 1 ms 2384 KB Output is correct
66 Correct 21 ms 6328 KB Output is correct
67 Correct 67 ms 11592 KB Output is correct
68 Correct 65 ms 10832 KB Output is correct
69 Correct 11 ms 5344 KB Output is correct
70 Correct 3 ms 2640 KB Output is correct
71 Correct 2 ms 2384 KB Output is correct
72 Correct 13 ms 5456 KB Output is correct
73 Correct 4 ms 2640 KB Output is correct
74 Correct 1 ms 2384 KB Output is correct
75 Correct 65 ms 10772 KB Output is correct
76 Correct 67 ms 10824 KB Output is correct
77 Correct 69 ms 10824 KB Output is correct
78 Correct 77 ms 10824 KB Output is correct
79 Correct 103 ms 10944 KB Output is correct
80 Correct 86 ms 10776 KB Output is correct
81 Correct 74 ms 8776 KB Output is correct
82 Correct 77 ms 8900 KB Output is correct