답안 #159758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
159758 2019-10-24T13:12:57 Z Rouge_Hugo Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
81 ms 1272 KB
#include <bits/stdc++.h>

using namespace std;
int n,q;
long long dp[10009];
int a[10009];
long long  d(int x)
{
    if (x==0)return 0;
    if (dp[x]!=-1)return dp[x];
    long long mn=1000000000;
    for(int i=0;i<n;i++)
    {
        if (x%a[i]!=0)mn=min(mn,1+d(x-(x%a[i])));
    }
    return dp[x]=mn;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>q;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    int x;
    memset (dp,-1,sizeof dp);
    while (q--)
    {
        cin>>x;
        long long u=d(x);
        if (u>=1000000)cout<<"oo"<<endl;
        else cout<<u<<endl;

    }

}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 508 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 34 ms 632 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 5 ms 504 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 2 ms 380 KB Output is correct
10 Correct 6 ms 504 KB Output is correct
11 Correct 6 ms 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 62 ms 632 KB Output is correct
14 Correct 81 ms 504 KB Output is correct
15 Correct 4 ms 504 KB Output is correct
16 Correct 5 ms 504 KB Output is correct
17 Correct 33 ms 504 KB Output is correct
18 Correct 33 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 6 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 4 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 6 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 6 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 6 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 6 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 860 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 6 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 3 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 6 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 6 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 3 ms 892 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 6 ms 1016 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 4 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 4 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 6 ms 1272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 6 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 3 ms 888 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 7 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 7 ms 1148 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 3 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 3 ms 636 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 6 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 3 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 4 ms 1036 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 6 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 3 ms 760 KB Execution killed with signal 11 (could be triggered by violating memory limits)