답안 #155866

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155866 2019-10-01T09:44:02 Z HellAngel Brunhilda’s Birthday (BOI13_brunhilda) C++14
97.7778 / 100
986 ms 253484 KB
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int maxn = 1e5 + 7;
const int maxans = 1e7 + 6e6;
int m, q, p[maxn], last[maxans], dp[maxans];

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
    cin >> m >> q;
    for(int i = 1; i <= m; i++)
    {
        cin >> p[i];
        for(int j = p[i] - 1; j < maxans; j += p[i])
        {
            last[j] = p[i] - 1;
        }
    }
    for(int i = maxans - 2; i >= 0; i--)
    {
        last[i] = max(last[i], last[i + 1] - 1);
    }
    for(int i = 1; i < maxans; i++)
    {
        if(last[i] != 0)
        dp[i] = dp[i - last[i]] + 1;
    }
    for(int i = 1; i <= q; i++)
    {
        int x;
        cin >> x;
        if(dp[x] == 0) cout << "oo" << '\n';
        else cout << dp[x] << '\n';
    }
}

Compilation message

brunhilda.cpp: In function 'int32_t main()':
brunhilda.cpp:13:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
brunhilda.cpp:13:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
# 결과 실행 시간 메모리 Grader output
1 Incorrect 350 ms 250844 KB Output isn't correct
2 Correct 340 ms 251004 KB Output is correct
3 Correct 317 ms 250872 KB Output is correct
4 Correct 287 ms 250956 KB Output is correct
5 Correct 315 ms 250844 KB Output is correct
6 Incorrect 301 ms 250828 KB Output isn't correct
7 Correct 319 ms 250872 KB Output is correct
8 Correct 349 ms 250848 KB Output is correct
9 Correct 443 ms 250900 KB Output is correct
10 Correct 494 ms 250872 KB Output is correct
11 Correct 467 ms 251000 KB Output is correct
12 Correct 286 ms 250820 KB Output is correct
13 Correct 708 ms 251000 KB Output is correct
14 Correct 661 ms 251040 KB Output is correct
15 Correct 361 ms 250872 KB Output is correct
16 Correct 341 ms 250900 KB Output is correct
17 Correct 334 ms 250992 KB Output is correct
18 Correct 286 ms 250872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 331 ms 251132 KB Output is correct
2 Correct 360 ms 252308 KB Output is correct
3 Correct 854 ms 251996 KB Output is correct
4 Correct 373 ms 250872 KB Output is correct
5 Correct 577 ms 251640 KB Output is correct
6 Correct 332 ms 250872 KB Output is correct
7 Correct 323 ms 250992 KB Output is correct
8 Correct 371 ms 250828 KB Output is correct
9 Correct 644 ms 251932 KB Output is correct
10 Correct 799 ms 252024 KB Output is correct
11 Correct 765 ms 251476 KB Output is correct
12 Correct 538 ms 251044 KB Output is correct
13 Correct 304 ms 250876 KB Output is correct
14 Correct 427 ms 250872 KB Output is correct
15 Correct 712 ms 251516 KB Output is correct
16 Correct 375 ms 252544 KB Output is correct
17 Correct 672 ms 250808 KB Output is correct
18 Correct 663 ms 252652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 692 ms 252012 KB Output is correct
2 Correct 821 ms 251896 KB Output is correct
3 Correct 806 ms 252280 KB Output is correct
4 Correct 511 ms 251744 KB Output is correct
5 Correct 411 ms 253364 KB Output is correct
6 Correct 665 ms 251896 KB Output is correct
7 Correct 584 ms 252884 KB Output is correct
8 Correct 673 ms 251928 KB Output is correct
9 Correct 694 ms 252008 KB Output is correct
10 Correct 551 ms 251036 KB Output is correct
11 Correct 476 ms 251136 KB Output is correct
12 Correct 622 ms 251264 KB Output is correct
13 Correct 760 ms 252280 KB Output is correct
14 Correct 469 ms 252244 KB Output is correct
15 Correct 651 ms 251256 KB Output is correct
16 Correct 814 ms 251128 KB Output is correct
17 Correct 657 ms 251828 KB Output is correct
18 Correct 804 ms 252152 KB Output is correct
19 Correct 335 ms 251128 KB Output is correct
20 Correct 858 ms 252152 KB Output is correct
21 Correct 637 ms 252240 KB Output is correct
22 Correct 986 ms 253304 KB Output is correct
23 Correct 408 ms 252240 KB Output is correct
24 Correct 338 ms 251668 KB Output is correct
25 Correct 590 ms 251948 KB Output is correct
26 Correct 511 ms 251896 KB Output is correct
27 Correct 862 ms 252848 KB Output is correct
28 Correct 361 ms 251992 KB Output is correct
29 Correct 750 ms 253248 KB Output is correct
30 Correct 682 ms 252920 KB Output is correct
31 Correct 386 ms 251764 KB Output is correct
32 Correct 419 ms 251812 KB Output is correct
33 Correct 312 ms 251892 KB Output is correct
34 Correct 577 ms 252920 KB Output is correct
35 Correct 362 ms 251988 KB Output is correct
36 Correct 802 ms 253176 KB Output is correct
37 Correct 449 ms 253484 KB Output is correct
38 Correct 662 ms 251896 KB Output is correct
39 Correct 362 ms 251968 KB Output is correct
40 Correct 577 ms 251984 KB Output is correct
41 Correct 524 ms 252892 KB Output is correct
42 Correct 811 ms 252256 KB Output is correct