답안 #631376

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
631376 2022-08-18T04:09:54 Z anhduc2701 Brunhilda’s Birthday (BOI13_brunhilda) C++17
100 / 100
571 ms 157352 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 2e7 + 10;
const int INF = 1e10;
int dp[maxn];
int n, m;
signed main()
{
    cin.tie(0),cout.tie(0)->sync_with_stdio;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        int p;
        cin >> p;
        for (int j = p - 1; j < maxn; j += p)
        {
            dp[j] = p - 1;
        }
    }
    for (int i = maxn - 2; i > 0; i--)
    {
        dp[i] = max(dp[i + 1] - 1, dp[i]);
    }
    for (int i = 1; i < maxn; i++)
    {
        if (dp[i] > 0)
        {
            dp[i] = dp[i - dp[i]] + 1;
        }
        else
        {
            dp[i] = INF;
        }
    }
    for (int i = 1; i <= m; i++)
    {
        int q;
        cin >> q;
        if(dp[q]>=INF){
            cout<<"oo"<<'\n';
        }
        else{
            cout<<dp[q]<<"\n";
        }
    }
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:10:29: warning: right operand of comma operator is a reference, not call, to function 'std::cout.std::basic_ostream<char>::<anonymous>.std::basic_ios<char>::tie(0)->std::ios_base::sync_with_stdio' [-Waddress]
   10 |     cin.tie(0),cout.tie(0)->sync_with_stdio;
      |                ~~~~~~~~~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 168 ms 156836 KB Output is correct
2 Correct 197 ms 156840 KB Output is correct
3 Correct 182 ms 157004 KB Output is correct
4 Correct 159 ms 156836 KB Output is correct
5 Correct 194 ms 156876 KB Output is correct
6 Correct 167 ms 156736 KB Output is correct
7 Correct 191 ms 156836 KB Output is correct
8 Correct 206 ms 156836 KB Output is correct
9 Correct 235 ms 156716 KB Output is correct
10 Correct 264 ms 156712 KB Output is correct
11 Correct 276 ms 156876 KB Output is correct
12 Correct 184 ms 156744 KB Output is correct
13 Correct 438 ms 156836 KB Output is correct
14 Correct 452 ms 156768 KB Output is correct
15 Correct 247 ms 156836 KB Output is correct
16 Correct 213 ms 156832 KB Output is correct
17 Correct 208 ms 156856 KB Output is correct
18 Correct 184 ms 156792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 208 ms 156840 KB Output is correct
2 Correct 257 ms 156836 KB Output is correct
3 Correct 568 ms 156832 KB Output is correct
4 Correct 238 ms 156836 KB Output is correct
5 Correct 378 ms 156840 KB Output is correct
6 Correct 216 ms 156840 KB Output is correct
7 Correct 195 ms 156832 KB Output is correct
8 Correct 224 ms 156832 KB Output is correct
9 Correct 413 ms 156784 KB Output is correct
10 Correct 496 ms 156832 KB Output is correct
11 Correct 459 ms 156836 KB Output is correct
12 Correct 282 ms 156840 KB Output is correct
13 Correct 180 ms 156784 KB Output is correct
14 Correct 212 ms 156836 KB Output is correct
15 Correct 456 ms 156836 KB Output is correct
16 Correct 224 ms 156728 KB Output is correct
17 Correct 400 ms 156840 KB Output is correct
18 Correct 420 ms 156884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 450 ms 156832 KB Output is correct
2 Correct 481 ms 157004 KB Output is correct
3 Correct 518 ms 156968 KB Output is correct
4 Correct 334 ms 157092 KB Output is correct
5 Correct 290 ms 156996 KB Output is correct
6 Correct 427 ms 157100 KB Output is correct
7 Correct 377 ms 156840 KB Output is correct
8 Correct 436 ms 156836 KB Output is correct
9 Correct 433 ms 156860 KB Output is correct
10 Correct 324 ms 156836 KB Output is correct
11 Correct 283 ms 156836 KB Output is correct
12 Correct 380 ms 156836 KB Output is correct
13 Correct 488 ms 157004 KB Output is correct
14 Correct 317 ms 157296 KB Output is correct
15 Correct 391 ms 156848 KB Output is correct
16 Correct 480 ms 156836 KB Output is correct
17 Correct 395 ms 156840 KB Output is correct
18 Correct 493 ms 156836 KB Output is correct
19 Correct 210 ms 156836 KB Output is correct
20 Correct 493 ms 157052 KB Output is correct
21 Correct 363 ms 157352 KB Output is correct
22 Correct 549 ms 157016 KB Output is correct
23 Correct 258 ms 156960 KB Output is correct
24 Correct 213 ms 157100 KB Output is correct
25 Correct 337 ms 157100 KB Output is correct
26 Correct 320 ms 157092 KB Output is correct
27 Correct 571 ms 156896 KB Output is correct
28 Correct 225 ms 157132 KB Output is correct
29 Correct 493 ms 157020 KB Output is correct
30 Correct 421 ms 156960 KB Output is correct
31 Correct 244 ms 156956 KB Output is correct
32 Correct 279 ms 157092 KB Output is correct
33 Correct 202 ms 157004 KB Output is correct
34 Correct 381 ms 156864 KB Output is correct
35 Correct 240 ms 157092 KB Output is correct
36 Correct 498 ms 156956 KB Output is correct
37 Correct 340 ms 156948 KB Output is correct
38 Correct 410 ms 157188 KB Output is correct
39 Correct 241 ms 157116 KB Output is correct
40 Correct 366 ms 157000 KB Output is correct
41 Correct 332 ms 156948 KB Output is correct
42 Correct 452 ms 157216 KB Output is correct