답안 #535229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535229 2022-03-09T17:50:06 Z MKutayBozkurt Brunhilda’s Birthday (BOI13_brunhilda) C++14
77.4603 / 100
480 ms 159312 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  int n, q; cin >> n >> q;
  vector<int> a(n), d((int) 1e7 + 7), dp((int) 1e7 + 7, 1e9);
  for (int &x : a) {
    cin >> x;
    for (int i = x - 1; i <= 1e7; i += x) {
      d[i] = max(d[i], x - 1);
    }
  }

  for (int i = 1e7; i > 0; i--) d[i] = max(d[i], d[i + 1] - 1);

  dp[0] = 0;
  for (int i = 1; i <= 1e7; i++) {
    dp[i] = dp[i - d[i]] + 1;
  }

  while (q--) {
    int x; cin >> x;
    cout << (dp[x] >= 1e9 ? "oo" : to_string(dp[x])) << '\n';
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 133 ms 156980 KB Output is correct
2 Correct 160 ms 156928 KB Output is correct
3 Correct 165 ms 156848 KB Output is correct
4 Correct 121 ms 156920 KB Output is correct
5 Correct 143 ms 156868 KB Output is correct
6 Correct 132 ms 156876 KB Output is correct
7 Correct 156 ms 156872 KB Output is correct
8 Correct 162 ms 156868 KB Output is correct
9 Correct 211 ms 156868 KB Output is correct
10 Correct 200 ms 156880 KB Output is correct
11 Correct 198 ms 156876 KB Output is correct
12 Correct 140 ms 156860 KB Output is correct
13 Correct 310 ms 156928 KB Output is correct
14 Correct 307 ms 156920 KB Output is correct
15 Correct 178 ms 156828 KB Output is correct
16 Correct 171 ms 156868 KB Output is correct
17 Correct 147 ms 156860 KB Output is correct
18 Correct 124 ms 156916 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 152 ms 157048 KB Output is correct
2 Correct 152 ms 158232 KB Output is correct
3 Correct 379 ms 157844 KB Output is correct
4 Correct 181 ms 156820 KB Output is correct
5 Correct 314 ms 157600 KB Output is correct
6 Correct 157 ms 156888 KB Output is correct
7 Correct 148 ms 156920 KB Output is correct
8 Correct 210 ms 156892 KB Output is correct
9 Correct 322 ms 157892 KB Output is correct
10 Correct 393 ms 157888 KB Output is correct
11 Incorrect 387 ms 157372 KB Output isn't correct
12 Correct 230 ms 156996 KB Output is correct
13 Correct 161 ms 156860 KB Output is correct
14 Correct 198 ms 156944 KB Output is correct
15 Correct 343 ms 157500 KB Output is correct
16 Correct 166 ms 158164 KB Output is correct
17 Correct 327 ms 157016 KB Output is correct
18 Correct 320 ms 158428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 374 ms 157948 KB Output is correct
2 Correct 464 ms 157780 KB Output is correct
3 Correct 480 ms 158132 KB Output is correct
4 Incorrect 268 ms 157816 KB Output isn't correct
5 Incorrect 212 ms 159312 KB Output isn't correct
6 Correct 322 ms 157892 KB Output is correct
7 Correct 345 ms 158904 KB Output is correct
8 Correct 324 ms 158016 KB Output is correct
9 Correct 365 ms 157888 KB Output is correct
10 Correct 247 ms 156960 KB Output is correct
11 Incorrect 222 ms 157148 KB Output isn't correct
12 Correct 308 ms 157168 KB Output is correct
13 Correct 360 ms 158276 KB Output is correct
14 Correct 256 ms 158172 KB Output is correct
15 Incorrect 305 ms 157128 KB Output isn't correct
16 Correct 352 ms 157100 KB Output is correct
17 Correct 317 ms 157628 KB Output is correct
18 Correct 393 ms 157844 KB Output is correct
19 Incorrect 155 ms 157124 KB Output isn't correct
20 Correct 412 ms 158200 KB Output is correct
21 Incorrect 284 ms 158236 KB Output isn't correct
22 Correct 455 ms 159304 KB Output is correct
23 Correct 201 ms 158240 KB Output is correct
24 Correct 176 ms 157828 KB Output is correct
25 Incorrect 264 ms 157908 KB Output isn't correct
26 Incorrect 310 ms 157764 KB Output isn't correct
27 Correct 429 ms 158920 KB Output is correct
28 Incorrect 197 ms 158040 KB Output isn't correct
29 Correct 359 ms 159284 KB Output is correct
30 Correct 352 ms 158788 KB Output is correct
31 Correct 187 ms 157784 KB Output is correct
32 Incorrect 237 ms 157920 KB Output isn't correct
33 Incorrect 152 ms 157764 KB Output isn't correct
34 Correct 270 ms 158904 KB Output is correct
35 Incorrect 191 ms 157868 KB Output isn't correct
36 Correct 378 ms 159104 KB Output is correct
37 Incorrect 203 ms 159248 KB Output isn't correct
38 Correct 312 ms 157944 KB Output is correct
39 Incorrect 181 ms 157896 KB Output isn't correct
40 Correct 291 ms 157932 KB Output is correct
41 Correct 265 ms 158912 KB Output is correct
42 Incorrect 348 ms 158136 KB Output isn't correct