답안 #155867

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

using namespace std;
const int maxn = 1e5 + 7;
const int maxans = 3e7 + 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 Runtime error 205 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 219 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 210 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 227 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 228 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 199 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 223 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 235 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 241 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 204 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 202 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 198 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 207 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 209 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 222 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 235 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 227 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 198 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 203 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 201 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 210 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 207 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 208 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 209 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 211 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 200 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 204 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 229 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 208 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 204 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 203 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 201 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 207 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 200 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 206 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 208 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 217 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 207 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 209 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 205 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 206 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 206 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 198 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 206 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 211 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 201 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 200 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 204 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 210 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 240 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 203 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 205 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 203 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 204 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 200 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 205 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
21 Runtime error 204 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 218 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
23 Runtime error 213 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
24 Runtime error 196 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
25 Runtime error 204 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
26 Runtime error 232 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
27 Runtime error 211 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
28 Runtime error 200 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Runtime error 195 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
30 Runtime error 199 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Runtime error 199 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
32 Runtime error 202 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
33 Runtime error 227 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
34 Runtime error 200 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
35 Runtime error 232 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
36 Runtime error 204 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
37 Runtime error 203 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
38 Runtime error 204 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Runtime error 200 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
40 Runtime error 225 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
41 Runtime error 205 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
42 Runtime error 226 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)