답안 #1015944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015944 2024-07-07T06:27:03 Z caterpillow Brunhilda’s Birthday (BOI13_brunhilda) C++17
8.09524 / 100
77 ms 41988 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pl = pair<ll, ll>;
using pi = pair<int, int>;
#define vt vector
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(), x.end() 
#define size(x) ((int) (x).size())
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define ROF(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define F0R(i, b) FOR (i, 0, b)
#define endl '\n'
const ll INF = 1e18;
const int inf = 1e9;

template<template<typename> class Container, typename T>
ostream& operator<<(ostream& os, Container<T> o) {
    os << "{"; 
    int g = size(o); 
    for (auto i : o) os << i << ((--g) == 0 ? "" : ", "); 
    os << "}";
    return os;
}

void _print() {
    cerr << "\n";
}

template<typename T, typename ...V>
void _print(T t, V... v) {
    cerr << t; if (sizeof...(v)) cerr << ", "; _print(v...);
}

#ifdef LOCAL
#define dbg(x...) cerr << #x << " = "; _print(x);
#else
#define dbg(x...)
#define cerr if (0) std::cerr
#endif

const int maxn = 1e7 + 1;

int m, qs; 
int dp[maxn];
vt<int> primes, ans;
vt<pi> queries;
priority_queue<pi, vt<pi>, greater<pi>> q;

main() {
    cin.tie(0)->sync_with_stdio(0);
    
    cin >> m >> qs;
    primes.resize(m);
    F0R (i, m) cin >> primes[i]; 
    memset(dp, 0x3f, sizeof(dp));
    dp[0] = 0;
    for (int p : primes) q.push({0, p});

    queries.resize(qs);
    F0R (i, qs) cin >> queries[i].f, queries[i].s = i;
    sort(all(queries));
    reverse(all(queries));
    ans.resize(qs, -1);

    FOR (i, 1, maxn) {
        while (q.top().f + q.top().s == i) {
            q.push({q.top().f + q.top().s, q.top().s});
            q.pop();
        }
        if (q.top().f == i) break;
        dp[i] = dp[q.top().f] + 1;
        while (size(queries) && queries.back().f == i) {
            ans[queries.back().s] = dp[i];
            queries.pop_back();
        }
        if (!size(q)) break;
    }
    F0R (i, qs) {
        if (ans[i] == -1) cout << "oo\n"; 
        else cout << ans[i] << endl;
    }
}

Compilation message

brunhilda.cpp:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 39516 KB Output isn't correct
2 Incorrect 33 ms 39600 KB Output isn't correct
3 Incorrect 35 ms 39512 KB Output isn't correct
4 Incorrect 36 ms 39516 KB Output isn't correct
5 Incorrect 35 ms 39380 KB Output isn't correct
6 Incorrect 35 ms 39444 KB Output isn't correct
7 Incorrect 33 ms 39516 KB Output isn't correct
8 Incorrect 36 ms 39516 KB Output isn't correct
9 Incorrect 32 ms 39516 KB Output isn't correct
10 Incorrect 30 ms 39516 KB Output isn't correct
11 Incorrect 32 ms 39516 KB Output isn't correct
12 Correct 33 ms 39516 KB Output is correct
13 Correct 43 ms 39512 KB Output is correct
14 Correct 41 ms 39516 KB Output is correct
15 Incorrect 32 ms 39516 KB Output isn't correct
16 Incorrect 39 ms 39760 KB Output isn't correct
17 Incorrect 36 ms 39512 KB Output isn't correct
18 Incorrect 37 ms 39512 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 45 ms 39768 KB Output isn't correct
2 Correct 55 ms 41116 KB Output is correct
3 Incorrect 46 ms 40924 KB Output isn't correct
4 Incorrect 43 ms 39512 KB Output isn't correct
5 Incorrect 41 ms 40416 KB Output isn't correct
6 Incorrect 35 ms 39516 KB Output isn't correct
7 Incorrect 40 ms 39796 KB Output isn't correct
8 Incorrect 37 ms 39512 KB Output isn't correct
9 Correct 44 ms 40924 KB Output is correct
10 Incorrect 50 ms 40924 KB Output isn't correct
11 Incorrect 44 ms 40160 KB Output isn't correct
12 Incorrect 40 ms 39632 KB Output isn't correct
13 Incorrect 42 ms 39512 KB Output isn't correct
14 Incorrect 51 ms 39476 KB Output isn't correct
15 Incorrect 45 ms 40412 KB Output isn't correct
16 Correct 56 ms 40920 KB Output is correct
17 Incorrect 43 ms 39512 KB Output isn't correct
18 Incorrect 57 ms 40924 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 40660 KB Output isn't correct
2 Incorrect 54 ms 40416 KB Output isn't correct
3 Incorrect 53 ms 40908 KB Output isn't correct
4 Incorrect 58 ms 40720 KB Output isn't correct
5 Incorrect 77 ms 41932 KB Output isn't correct
6 Incorrect 59 ms 40788 KB Output isn't correct
7 Incorrect 61 ms 41432 KB Output isn't correct
8 Incorrect 58 ms 40668 KB Output isn't correct
9 Incorrect 57 ms 40668 KB Output isn't correct
10 Incorrect 46 ms 39772 KB Output isn't correct
11 Incorrect 44 ms 39768 KB Output isn't correct
12 Incorrect 48 ms 39988 KB Output isn't correct
13 Incorrect 48 ms 41164 KB Output isn't correct
14 Incorrect 47 ms 40784 KB Output isn't correct
15 Incorrect 48 ms 40024 KB Output isn't correct
16 Incorrect 43 ms 40020 KB Output isn't correct
17 Incorrect 45 ms 40412 KB Output isn't correct
18 Incorrect 53 ms 40416 KB Output isn't correct
19 Incorrect 46 ms 39772 KB Output isn't correct
20 Incorrect 51 ms 40772 KB Output isn't correct
21 Incorrect 51 ms 40788 KB Output isn't correct
22 Incorrect 72 ms 41952 KB Output isn't correct
23 Incorrect 58 ms 41252 KB Output isn't correct
24 Incorrect 64 ms 40740 KB Output isn't correct
25 Incorrect 54 ms 40920 KB Output isn't correct
26 Incorrect 59 ms 40784 KB Output isn't correct
27 Incorrect 56 ms 41408 KB Output isn't correct
28 Incorrect 49 ms 40792 KB Output isn't correct
29 Incorrect 65 ms 41940 KB Output isn't correct
30 Incorrect 69 ms 41584 KB Output isn't correct
31 Incorrect 55 ms 40784 KB Output isn't correct
32 Incorrect 58 ms 40788 KB Output isn't correct
33 Incorrect 52 ms 40788 KB Output isn't correct
34 Incorrect 70 ms 41424 KB Output isn't correct
35 Incorrect 54 ms 40820 KB Output isn't correct
36 Incorrect 66 ms 41936 KB Output isn't correct
37 Incorrect 72 ms 41988 KB Output isn't correct
38 Incorrect 52 ms 40796 KB Output isn't correct
39 Incorrect 53 ms 40796 KB Output isn't correct
40 Incorrect 55 ms 41068 KB Output isn't correct
41 Correct 63 ms 41432 KB Output is correct
42 Incorrect 54 ms 40832 KB Output isn't correct