답안 #155870

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
155870 2019-10-01T10:02:51 Z HellAngel Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
399 ms 79224 KB
#include<bits/stdc++.h>
#define Task     "test"
#define pb       emplace_back
 
using namespace std;
 
const int N = int(1e7) + 1;
const int inf = int(1e9);
 
int nxt[N], f[N], m, Q, n, x;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> m >> Q;
    while(m --) {
       cin >> x;
       for(int i = x; i <= N; i += x) nxt[i - 1] = max(nxt[i - 1], x - 1);
       nxt[N - 1] = max(nxt[N - 1], (N - 1) % x);
    }
    for(int i = N - 1; i >= 1; --i) nxt[i] = max(nxt[i], nxt[i + 1] - 1);
    for(int i = 1; i < N; ++i) {
       if(nxt[i]) f[i] = f[i - nxt[i]] + 1;
       else f[i] = inf;
    }
    while(Q --) {
        cin >> x;
        if(f[x] >= inf) cout << "oo\n";
        else cout << f[x] << '\n';
    }
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".inp", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
brunhilda.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen(Task".out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 78688 KB Output is correct
2 Correct 158 ms 78588 KB Output is correct
3 Correct 166 ms 78712 KB Output is correct
4 Correct 150 ms 78560 KB Output is correct
5 Correct 162 ms 78592 KB Output is correct
6 Correct 145 ms 78560 KB Output is correct
7 Correct 152 ms 78728 KB Output is correct
8 Correct 175 ms 78556 KB Output is correct
9 Correct 197 ms 78608 KB Output is correct
10 Correct 244 ms 78744 KB Output is correct
11 Correct 215 ms 78584 KB Output is correct
12 Correct 151 ms 78588 KB Output is correct
13 Correct 353 ms 78632 KB Output is correct
14 Correct 284 ms 78584 KB Output is correct
15 Correct 194 ms 78584 KB Output is correct
16 Correct 173 ms 78708 KB Output is correct
17 Correct 246 ms 78676 KB Output is correct
18 Correct 151 ms 78584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 166 ms 78732 KB Output is correct
2 Correct 174 ms 78684 KB Output is correct
3 Correct 368 ms 78684 KB Output is correct
4 Correct 197 ms 78636 KB Output is correct
5 Correct 298 ms 78664 KB Output is correct
6 Correct 156 ms 78584 KB Output is correct
7 Correct 156 ms 78564 KB Output is correct
8 Correct 176 ms 78712 KB Output is correct
9 Correct 281 ms 78584 KB Output is correct
10 Correct 353 ms 78584 KB Output is correct
11 Correct 349 ms 78584 KB Output is correct
12 Correct 211 ms 78584 KB Output is correct
13 Correct 153 ms 78712 KB Output is correct
14 Correct 191 ms 78764 KB Output is correct
15 Correct 345 ms 78556 KB Output is correct
16 Correct 172 ms 78712 KB Output is correct
17 Correct 289 ms 78576 KB Output is correct
18 Correct 289 ms 78608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 292 ms 78712 KB Output is correct
2 Correct 352 ms 78712 KB Output is correct
3 Correct 353 ms 78812 KB Output is correct
4 Correct 246 ms 78968 KB Output is correct
5 Correct 206 ms 78840 KB Output is correct
6 Correct 313 ms 78968 KB Output is correct
7 Correct 298 ms 78764 KB Output is correct
8 Correct 312 ms 78712 KB Output is correct
9 Correct 348 ms 78696 KB Output is correct
10 Correct 296 ms 78688 KB Output is correct
11 Correct 219 ms 78744 KB Output is correct
12 Correct 320 ms 78684 KB Output is correct
13 Correct 399 ms 78944 KB Output is correct
14 Correct 256 ms 79208 KB Output is correct
15 Correct 318 ms 78724 KB Output is correct
16 Correct 320 ms 78712 KB Output is correct
17 Correct 284 ms 78688 KB Output is correct
18 Correct 350 ms 78712 KB Output is correct
19 Correct 172 ms 78712 KB Output is correct
20 Correct 393 ms 78900 KB Output is correct
21 Correct 243 ms 79224 KB Output is correct
22 Correct 380 ms 78840 KB Output is correct
23 Correct 201 ms 78840 KB Output is correct
24 Correct 174 ms 78968 KB Output is correct
25 Correct 256 ms 79000 KB Output is correct
26 Correct 245 ms 78840 KB Output is correct
27 Correct 395 ms 78840 KB Output is correct
28 Correct 173 ms 78968 KB Output is correct
29 Correct 367 ms 78740 KB Output is correct
30 Correct 326 ms 78840 KB Output is correct
31 Correct 213 ms 78812 KB Output is correct
32 Correct 242 ms 78968 KB Output is correct
33 Correct 181 ms 78968 KB Output is correct
34 Correct 278 ms 78840 KB Output is correct
35 Correct 177 ms 78968 KB Output is correct
36 Correct 368 ms 78840 KB Output is correct
37 Correct 205 ms 78840 KB Output is correct
38 Correct 325 ms 78856 KB Output is correct
39 Correct 183 ms 78840 KB Output is correct
40 Correct 270 ms 78840 KB Output is correct
41 Correct 252 ms 78712 KB Output is correct
42 Correct 330 ms 78968 KB Output is correct