답안 #632932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
632932 2022-08-21T08:43:17 Z minhnhatnoe Brunhilda’s Birthday (BOI13_brunhilda) C++14
80.3175 / 100
296 ms 80312 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int MAXN = 1e7+10;
vector<int> dist;
vector<int> step;

void build_dist(int m){
    dist.resize(MAXN);
    vector<int> prs(m);
    for (int i=0; i<m; i++) cin >> prs[i];
    sort(prs.begin(), prs.end());
    prs.resize(unique(prs.begin(), prs.end()) - prs.begin());
    for (int x: prs){
        for (int i=x-1; i<MAXN; i+=x){
            dist[i] = x-1;
        }
    }
    for (int i=MAXN-2; i>=0; i--){
        dist[i] = max(dist[i], dist[i+1]-1);
    }
}
void build_step(){
    step.reserve(MAXN);
    step.push_back(0);
    for (int i=1; i<MAXN && dist[i]; i++){
        step.push_back(step[i - dist[i]] + 1);
    }
}
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    int m, q; cin >> m >> q;
    build_dist(m);
    build_step();
    for (int i=0; i<q; i++){
        int val; cin >> val;
        if (val >= step.size()){
            cout << "oo\n";
        }
        else{
            cout << step[val] << "\n";
        }
    }
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:38:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (val >= step.size()){
      |             ~~~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 39380 KB Output is correct
2 Correct 121 ms 78500 KB Output is correct
3 Correct 73 ms 40376 KB Output is correct
4 Correct 109 ms 78580 KB Output is correct
5 Correct 116 ms 78592 KB Output is correct
6 Correct 64 ms 39456 KB Output is correct
7 Correct 70 ms 40488 KB Output is correct
8 Correct 85 ms 42904 KB Output is correct
9 Correct 130 ms 78492 KB Output is correct
10 Correct 148 ms 78500 KB Output is correct
11 Correct 152 ms 78496 KB Output is correct
12 Correct 108 ms 78560 KB Output is correct
13 Correct 204 ms 78540 KB Output is correct
14 Correct 207 ms 78560 KB Output is correct
15 Correct 127 ms 78508 KB Output is correct
16 Correct 122 ms 78504 KB Output is correct
17 Correct 119 ms 78552 KB Output is correct
18 Correct 108 ms 78756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 78628 KB Output is correct
2 Correct 133 ms 79324 KB Output is correct
3 Correct 240 ms 78964 KB Output is correct
4 Correct 135 ms 78540 KB Output is correct
5 Correct 180 ms 78856 KB Output is correct
6 Correct 122 ms 78508 KB Output is correct
7 Correct 120 ms 78620 KB Output is correct
8 Correct 131 ms 78504 KB Output is correct
9 Correct 197 ms 78992 KB Output is correct
10 Correct 247 ms 79048 KB Output is correct
11 Incorrect 248 ms 78768 KB Output isn't correct
12 Correct 153 ms 78544 KB Output is correct
13 Correct 113 ms 78564 KB Output is correct
14 Correct 145 ms 78612 KB Output is correct
15 Correct 207 ms 78800 KB Output is correct
16 Correct 125 ms 79196 KB Output is correct
17 Correct 215 ms 78524 KB Output is correct
18 Correct 213 ms 79236 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 210 ms 79240 KB Output is correct
2 Correct 262 ms 79112 KB Output is correct
3 Correct 260 ms 79528 KB Output is correct
4 Incorrect 196 ms 79780 KB Output isn't correct
5 Incorrect 153 ms 80252 KB Output isn't correct
6 Correct 215 ms 79676 KB Output is correct
7 Correct 194 ms 79848 KB Output is correct
8 Correct 219 ms 79244 KB Output is correct
9 Correct 233 ms 79240 KB Output is correct
10 Correct 176 ms 78764 KB Output is correct
11 Incorrect 171 ms 78764 KB Output isn't correct
12 Correct 199 ms 78896 KB Output is correct
13 Correct 241 ms 79872 KB Output is correct
14 Correct 185 ms 79860 KB Output is correct
15 Incorrect 209 ms 78880 KB Output isn't correct
16 Correct 222 ms 78884 KB Output is correct
17 Correct 214 ms 78888 KB Output is correct
18 Correct 255 ms 79108 KB Output is correct
19 Incorrect 119 ms 78768 KB Output isn't correct
20 Correct 296 ms 79616 KB Output is correct
21 Incorrect 180 ms 79932 KB Output isn't correct
22 Correct 290 ms 80312 KB Output is correct
23 Correct 174 ms 79820 KB Output is correct
24 Correct 135 ms 79572 KB Output is correct
25 Correct 187 ms 79564 KB Output is correct
26 Incorrect 187 ms 79556 KB Output isn't correct
27 Correct 261 ms 79808 KB Output is correct
28 Incorrect 132 ms 79576 KB Output isn't correct
29 Correct 257 ms 80264 KB Output is correct
30 Correct 226 ms 79984 KB Output is correct
31 Correct 157 ms 79512 KB Output is correct
32 Incorrect 184 ms 79600 KB Output isn't correct
33 Incorrect 132 ms 79480 KB Output isn't correct
34 Correct 192 ms 79816 KB Output is correct
35 Incorrect 157 ms 79676 KB Output isn't correct
36 Correct 259 ms 80120 KB Output is correct
37 Incorrect 145 ms 80216 KB Output isn't correct
38 Correct 223 ms 79644 KB Output is correct
39 Incorrect 148 ms 79648 KB Output isn't correct
40 Correct 197 ms 79656 KB Output is correct
41 Correct 189 ms 79760 KB Output is correct
42 Correct 232 ms 79756 KB Output is correct