답안 #682650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
682650 2023-01-16T17:00:33 Z peijar Self Study (JOI22_ho_t2) C++17
100 / 100
364 ms 11456 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

string to_string(string s) { return s; }
template <typename T> string to_string(T v) {
  bool first = true;
  string res = "[";
  for (const auto &x : v) {
    if (!first)
      res += ", ";
    first = false;
    res += to_string(x);
  }
  res += "]";
  return res;
}

void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
  cout << ' ' << to_string(H);
  dbg_out(T...);
}

#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

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

  int N, nbSemaines;
  cin >> N >> nbSemaines;
  vector<int> A(N), B(N);
  for (int &x : A)
    cin >> x;
  for (int i = 0; i < N; ++i) {
    cin >> B[i];
    A[i] = max(A[i], B[i]);
  }

  auto isGood = [&](int req) {
    int delta = 0;
    for (int i = 0; i < N; ++i) {
      int take = (req + A[i] - 1) / A[i];
      if (take <= nbSemaines)
        delta += nbSemaines - take;
      else
        delta -= (req - nbSemaines * A[i] + B[i] - 1) / B[i];
      if (delta < -(N - i - 1) * nbSemaines)
        return false;
    }
    return delta >= 0;
  };

  int lo = 0, up = 4e18;
  while (lo < up) {
    int mid = (lo + up + 1) / 2;
    if (isGood(mid))
      lo = mid;
    else
      up = mid - 1;
  }
  cout << lo << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 101 ms 4948 KB Output is correct
12 Correct 101 ms 5008 KB Output is correct
13 Correct 96 ms 4948 KB Output is correct
14 Correct 74 ms 5012 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 36 ms 6184 KB Output is correct
17 Correct 134 ms 11396 KB Output is correct
18 Correct 108 ms 10764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 36 ms 6184 KB Output is correct
3 Correct 134 ms 11396 KB Output is correct
4 Correct 108 ms 10764 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 0 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 2656 KB Output is correct
14 Correct 39 ms 1884 KB Output is correct
15 Correct 29 ms 1492 KB Output is correct
16 Correct 23 ms 1236 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 1 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 101 ms 4948 KB Output is correct
12 Correct 101 ms 5008 KB Output is correct
13 Correct 96 ms 4948 KB Output is correct
14 Correct 74 ms 5012 KB Output is correct
15 Correct 1 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 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 0 ms 212 KB Output is correct
23 Correct 55 ms 2656 KB Output is correct
24 Correct 39 ms 1884 KB Output is correct
25 Correct 29 ms 1492 KB Output is correct
26 Correct 23 ms 1236 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 36 ms 6184 KB Output is correct
36 Correct 134 ms 11396 KB Output is correct
37 Correct 108 ms 10764 KB Output is correct
38 Correct 1 ms 320 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 1 ms 212 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 3 ms 468 KB Output is correct
46 Correct 5 ms 596 KB Output is correct
47 Correct 1 ms 340 KB Output is correct
48 Correct 21 ms 2024 KB Output is correct
49 Correct 1 ms 316 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 2 ms 460 KB Output is correct
52 Correct 0 ms 320 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 212 KB Output is correct
55 Correct 57 ms 5456 KB Output is correct
56 Correct 41 ms 3164 KB Output is correct
57 Correct 29 ms 3144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 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 55 ms 2656 KB Output is correct
10 Correct 39 ms 1884 KB Output is correct
11 Correct 29 ms 1492 KB Output is correct
12 Correct 23 ms 1236 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 36 ms 6184 KB Output is correct
22 Correct 134 ms 11396 KB Output is correct
23 Correct 108 ms 10764 KB Output is correct
24 Correct 33 ms 1940 KB Output is correct
25 Correct 78 ms 5020 KB Output is correct
26 Correct 16 ms 1324 KB Output is correct
27 Correct 102 ms 10816 KB Output is correct
28 Correct 118 ms 10812 KB Output is correct
29 Correct 119 ms 10748 KB Output is correct
30 Correct 142 ms 10752 KB Output is correct
31 Correct 232 ms 10752 KB Output is correct
32 Correct 151 ms 6180 KB Output is correct
33 Correct 364 ms 11456 KB Output is correct
34 Correct 173 ms 6180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 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 0 ms 212 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 101 ms 4948 KB Output is correct
12 Correct 101 ms 5008 KB Output is correct
13 Correct 96 ms 4948 KB Output is correct
14 Correct 74 ms 5012 KB Output is correct
15 Correct 1 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 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 0 ms 212 KB Output is correct
23 Correct 55 ms 2656 KB Output is correct
24 Correct 39 ms 1884 KB Output is correct
25 Correct 29 ms 1492 KB Output is correct
26 Correct 23 ms 1236 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 320 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 212 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 3 ms 468 KB Output is correct
42 Correct 5 ms 596 KB Output is correct
43 Correct 1 ms 340 KB Output is correct
44 Correct 21 ms 2024 KB Output is correct
45 Correct 1 ms 316 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 2 ms 460 KB Output is correct
48 Correct 0 ms 320 KB Output is correct
49 Correct 1 ms 212 KB Output is correct
50 Correct 1 ms 212 KB Output is correct
51 Correct 57 ms 5456 KB Output is correct
52 Correct 41 ms 3164 KB Output is correct
53 Correct 29 ms 3144 KB Output is correct
54 Correct 33 ms 1940 KB Output is correct
55 Correct 78 ms 5020 KB Output is correct
56 Correct 16 ms 1324 KB Output is correct
57 Correct 102 ms 10816 KB Output is correct
58 Correct 118 ms 10812 KB Output is correct
59 Correct 119 ms 10748 KB Output is correct
60 Correct 142 ms 10752 KB Output is correct
61 Correct 232 ms 10752 KB Output is correct
62 Correct 151 ms 6180 KB Output is correct
63 Correct 364 ms 11456 KB Output is correct
64 Correct 173 ms 6180 KB Output is correct
65 Correct 1 ms 212 KB Output is correct
66 Correct 36 ms 6184 KB Output is correct
67 Correct 134 ms 11396 KB Output is correct
68 Correct 108 ms 10764 KB Output is correct
69 Correct 28 ms 1476 KB Output is correct
70 Correct 7 ms 596 KB Output is correct
71 Correct 1 ms 320 KB Output is correct
72 Correct 38 ms 1844 KB Output is correct
73 Correct 7 ms 668 KB Output is correct
74 Correct 1 ms 336 KB Output is correct
75 Correct 117 ms 10768 KB Output is correct
76 Correct 129 ms 10804 KB Output is correct
77 Correct 149 ms 10804 KB Output is correct
78 Correct 180 ms 10748 KB Output is correct
79 Correct 242 ms 10804 KB Output is correct
80 Correct 275 ms 10828 KB Output is correct
81 Correct 327 ms 8820 KB Output is correct
82 Correct 220 ms 8908 KB Output is correct