답안 #242156

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
242156 2020-06-27T03:08:16 Z thecodingwizard Brunhilda’s Birthday (BOI13_brunhilda) C++11
6.66667 / 100
297 ms 262148 KB
#include <bits/stdc++.h>

using namespace std;

#define ii pair<int, int>
#define f first
#define s second

int A[100000]; 
int dp[10000001]; 
vector<int> transitions[10000001];

int main() {
    int m, q; cin >> m >> q;
    for (int i = 0; i < m; i++) cin >> A[i];
    for (int i = 0; i < 1000001; i++) dp[i] = -1;
    dp[0] = 0;

    int nxtStart = 0, nxtVal = 0;
    for (int i = 0; i < m; i++) {
        nxtVal = max(nxtVal, A[i]);

        transitions[A[i]].push_back(A[i]);
    }

    while (nxtStart != -1) {
        int begin = nxtStart, end = begin + nxtVal;
        nxtStart = -1;
        nxtVal = 0;

        end = min(end, 10000001);
        for (int i = begin + 1; i < end; i++) {
            for (int x : transitions[i]) {
                if (nxtStart+nxtVal < i + x) {
                    nxtStart = i;
                    nxtVal = x;
                }
                if (i+x<10000001) transitions[i+x].push_back(x);
            }
            transitions[i].clear();
            if (dp[i] == -1) dp[i] = dp[begin]+1;
        }
    }

    for (int i = 0; i < q; i++) {
        int x; cin >> x;
        if (dp[x] == -1) cout << "oo" << "\n";
        else cout << dp[x] << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 239096 KB Output is correct
2 Runtime error 189 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Correct 152 ms 244344 KB Output is correct
4 Runtime error 263 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 190 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Correct 137 ms 239096 KB Output is correct
7 Correct 155 ms 244216 KB Output is correct
8 Correct 203 ms 260344 KB Output is correct
9 Runtime error 188 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 203 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 190 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Correct 255 ms 255992 KB Output is correct
13 Runtime error 219 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 223 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 190 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 182 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 195 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 255 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 247 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 269 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 283 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 212 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 233 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 186 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 246 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 192 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 265 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 277 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
11 Runtime error 268 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 214 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 198 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 202 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 262 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 275 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 229 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 265 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 253 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 269 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 295 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 203 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 297 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 234 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 251 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 257 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 248 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 208 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
12 Runtime error 225 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
13 Runtime error 249 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
14 Runtime error 195 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
15 Runtime error 224 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
16 Runtime error 223 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
17 Runtime error 240 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
18 Runtime error 271 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
19 Runtime error 182 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
20 Runtime error 292 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
21 Runtime error 209 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
22 Runtime error 288 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
23 Runtime error 249 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
24 Runtime error 210 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
25 Runtime error 197 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
26 Runtime error 214 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
27 Runtime error 282 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
28 Runtime error 189 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
29 Runtime error 265 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
30 Runtime error 241 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
31 Runtime error 194 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
32 Runtime error 191 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
33 Runtime error 242 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
34 Runtime error 266 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
35 Runtime error 192 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
36 Runtime error 282 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
37 Runtime error 295 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
38 Runtime error 219 ms 262144 KB Execution killed with signal 9 (could be triggered by violating memory limits)
39 Runtime error 204 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
40 Runtime error 224 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
41 Runtime error 261 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
42 Runtime error 241 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)