답안 #493678

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493678 2021-12-12T14:31:52 Z goodluck2020 Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
160 ms 636 KB
#include <bits/stdc++.h>
#define task "brunhilda"

using namespace std;
const int N = 1e4 + 5;
int m, q, A[N];
namespace sub1
{
    int dp[N];
    void solve()
    {
        for(int i = 1; i <= 1e4; i++) dp[i] = 1e9;
        for(int i = 1; i <= 1e4; i++)
            for(int j = 1; j <= m; j++)
            dp[i] = min(dp[i], dp[i - i % A[j]] + 1);
        while(q--)
        {
            int n;
            cin >> n;
            if(dp[n] == 1e9) cout << "oo" << '\n';
            else cout << dp[n] << '\n';
        }
    }
}
int main()
{
    if(fopen(task ".inp","r"))
    {
        freopen(task ".inp","r",stdin);
        freopen(task ".out","w",stdout);
    }
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> m >> q;
    for(int i = 1; i <= m; i++) cin >> A[i];
    if(m <= 1e4 && q <= 1e4) sub1::solve();
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(task ".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
brunhilda.cpp:30:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         freopen(task ".out","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 6 ms 332 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 2 ms 332 KB Output is correct
12 Correct 6 ms 360 KB Output is correct
13 Correct 51 ms 328 KB Output is correct
14 Correct 54 ms 372 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 5 ms 332 KB Output is correct
18 Correct 6 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 588 KB Execution killed with signal 11
2 Runtime error 2 ms 588 KB Execution killed with signal 11
3 Runtime error 1 ms 588 KB Execution killed with signal 11
4 Runtime error 160 ms 492 KB Execution killed with signal 11
5 Runtime error 2 ms 588 KB Execution killed with signal 11
6 Runtime error 58 ms 488 KB Execution killed with signal 11
7 Runtime error 2 ms 588 KB Execution killed with signal 11
8 Runtime error 50 ms 492 KB Execution killed with signal 11
9 Runtime error 2 ms 588 KB Execution killed with signal 11
10 Runtime error 2 ms 588 KB Execution killed with signal 11
11 Runtime error 2 ms 540 KB Execution killed with signal 11
12 Runtime error 107 ms 488 KB Execution killed with signal 11
13 Runtime error 151 ms 472 KB Execution killed with signal 11
14 Runtime error 155 ms 480 KB Execution killed with signal 11
15 Runtime error 1 ms 460 KB Execution killed with signal 11
16 Runtime error 2 ms 460 KB Execution killed with signal 11
17 Runtime error 146 ms 504 KB Execution killed with signal 11
18 Runtime error 3 ms 460 KB Execution killed with signal 11
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 636 KB Execution killed with signal 11
2 Runtime error 2 ms 460 KB Execution killed with signal 11
3 Runtime error 2 ms 460 KB Execution killed with signal 11
4 Incorrect 1 ms 204 KB Output isn't correct
5 Runtime error 1 ms 460 KB Execution killed with signal 11
6 Incorrect 1 ms 332 KB Output isn't correct
7 Runtime error 1 ms 460 KB Execution killed with signal 11
8 Runtime error 2 ms 460 KB Execution killed with signal 11
9 Runtime error 2 ms 460 KB Execution killed with signal 11
10 Incorrect 1 ms 332 KB Output isn't correct
11 Incorrect 1 ms 332 KB Output isn't correct
12 Incorrect 1 ms 332 KB Output isn't correct
13 Runtime error 1 ms 460 KB Execution killed with signal 11
14 Incorrect 1 ms 256 KB Output isn't correct
15 Incorrect 1 ms 332 KB Output isn't correct
16 Incorrect 1 ms 332 KB Output isn't correct
17 Runtime error 2 ms 460 KB Execution killed with signal 11
18 Runtime error 1 ms 460 KB Execution killed with signal 11
19 Incorrect 1 ms 332 KB Output isn't correct
20 Runtime error 2 ms 460 KB Execution killed with signal 11
21 Incorrect 0 ms 332 KB Output isn't correct
22 Runtime error 2 ms 460 KB Execution killed with signal 11
23 Runtime error 2 ms 460 KB Execution killed with signal 11
24 Incorrect 1 ms 204 KB Output isn't correct
25 Incorrect 1 ms 204 KB Output isn't correct
26 Incorrect 1 ms 332 KB Output isn't correct
27 Runtime error 1 ms 460 KB Execution killed with signal 11
28 Incorrect 0 ms 204 KB Output isn't correct
29 Runtime error 1 ms 460 KB Execution killed with signal 11
30 Runtime error 1 ms 460 KB Execution killed with signal 11
31 Incorrect 0 ms 332 KB Output isn't correct
32 Incorrect 1 ms 204 KB Output isn't correct
33 Incorrect 1 ms 204 KB Output isn't correct
34 Runtime error 2 ms 460 KB Execution killed with signal 11
35 Incorrect 1 ms 204 KB Output isn't correct
36 Runtime error 2 ms 460 KB Execution killed with signal 11
37 Runtime error 1 ms 460 KB Execution killed with signal 11
38 Incorrect 1 ms 332 KB Output isn't correct
39 Incorrect 1 ms 332 KB Output isn't correct
40 Incorrect 2 ms 332 KB Output isn't correct
41 Runtime error 2 ms 556 KB Execution killed with signal 11
42 Incorrect 1 ms 332 KB Output isn't correct