답안 #1015959

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015959 2024-07-07T06:45:34 Z caterpillow Brunhilda’s Birthday (BOI13_brunhilda) C++17
61.4286 / 100
1000 ms 43052 KB
#include <bits/stdc++.h>
 
using namespace std;

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
 
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;
 
const int maxn = 1e7 + 1;
 
int m, qs; 
int dp[maxn];
vt<int> primes, ans;
vt<pi> queries;
priority_queue<pi> q;
 
main() {
    cin.tie(0)->sync_with_stdio(0);
    
    cin >> m >> qs;
    primes.resize(m);
    F0R (i, m) cin >> primes[i]; 
    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:32:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   32 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 282 ms 39544 KB Output is correct
3 Correct 6 ms 2648 KB Output is correct
4 Correct 70 ms 39764 KB Output is correct
5 Correct 142 ms 39508 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 5 ms 2652 KB Output is correct
8 Correct 23 ms 3984 KB Output is correct
9 Correct 396 ms 39572 KB Output is correct
10 Correct 485 ms 39580 KB Output is correct
11 Correct 389 ms 39360 KB Output is correct
12 Correct 48 ms 39504 KB Output is correct
13 Execution timed out 1028 ms 30608 KB Time limit exceeded
14 Execution timed out 1069 ms 33064 KB Time limit exceeded
15 Correct 335 ms 39512 KB Output is correct
16 Correct 295 ms 39556 KB Output is correct
17 Correct 149 ms 39596 KB Output is correct
18 Correct 63 ms 39504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 39760 KB Output is correct
2 Correct 142 ms 41168 KB Output is correct
3 Execution timed out 1076 ms 24916 KB Time limit exceeded
4 Correct 369 ms 39504 KB Output is correct
5 Correct 967 ms 40608 KB Output is correct
6 Correct 318 ms 39508 KB Output is correct
7 Correct 161 ms 39764 KB Output is correct
8 Correct 282 ms 39504 KB Output is correct
9 Execution timed out 1066 ms 37028 KB Time limit exceeded
10 Execution timed out 1040 ms 24916 KB Time limit exceeded
11 Execution timed out 1064 ms 23004 KB Time limit exceeded
12 Correct 645 ms 39464 KB Output is correct
13 Correct 144 ms 39508 KB Output is correct
14 Correct 318 ms 39636 KB Output is correct
15 Execution timed out 1055 ms 30996 KB Time limit exceeded
16 Correct 143 ms 41244 KB Output is correct
17 Execution timed out 1074 ms 30260 KB Time limit exceeded
18 Execution timed out 1099 ms 40920 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1063 ms 31048 KB Time limit exceeded
2 Execution timed out 1069 ms 23764 KB Time limit exceeded
3 Execution timed out 1060 ms 24660 KB Time limit exceeded
4 Correct 725 ms 41296 KB Output is correct
5 Correct 223 ms 43052 KB Output is correct
6 Execution timed out 1028 ms 32344 KB Time limit exceeded
7 Correct 791 ms 42076 KB Output is correct
8 Execution timed out 1008 ms 28388 KB Time limit exceeded
9 Execution timed out 1004 ms 28820 KB Time limit exceeded
10 Correct 754 ms 39880 KB Output is correct
11 Correct 545 ms 40128 KB Output is correct
12 Execution timed out 1056 ms 40080 KB Time limit exceeded
13 Execution timed out 1068 ms 30416 KB Time limit exceeded
14 Correct 609 ms 41652 KB Output is correct
15 Execution timed out 1004 ms 29064 KB Time limit exceeded
16 Execution timed out 1068 ms 25940 KB Time limit exceeded
17 Execution timed out 1024 ms 34716 KB Time limit exceeded
18 Execution timed out 1045 ms 23748 KB Time limit exceeded
19 Correct 223 ms 40144 KB Output is correct
20 Execution timed out 1047 ms 22736 KB Time limit exceeded
21 Correct 884 ms 42068 KB Output is correct
22 Execution timed out 1030 ms 27320 KB Time limit exceeded
23 Correct 298 ms 42188 KB Output is correct
24 Correct 147 ms 41468 KB Output is correct
25 Correct 787 ms 41552 KB Output is correct
26 Correct 779 ms 41372 KB Output is correct
27 Execution timed out 1060 ms 24568 KB Time limit exceeded
28 Correct 211 ms 41824 KB Output is correct
29 Execution timed out 1052 ms 36788 KB Time limit exceeded
30 Execution timed out 1039 ms 39796 KB Time limit exceeded
31 Correct 272 ms 41300 KB Output is correct
32 Correct 430 ms 41476 KB Output is correct
33 Correct 98 ms 41356 KB Output is correct
34 Correct 767 ms 42192 KB Output is correct
35 Correct 279 ms 41788 KB Output is correct
36 Execution timed out 1046 ms 28624 KB Time limit exceeded
37 Correct 236 ms 42908 KB Output is correct
38 Execution timed out 1098 ms 35664 KB Time limit exceeded
39 Correct 212 ms 42064 KB Output is correct
40 Correct 992 ms 41592 KB Output is correct
41 Correct 737 ms 42148 KB Output is correct
42 Execution timed out 1099 ms 30800 KB Time limit exceeded