Submission #283112

# Submission time Handle Problem Language Result Execution time Memory
283112 2020-08-25T10:07:32 Z egekabas Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
44 ms 4584 KB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, q;
int p[100009];
vector<pii> ans;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    srand(time(NULL));
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> q;
    for(int i = 0; i < n; ++i)
        cin >> p[i];
    reverse(p, p+n);
    ans.pb({0, 0});
    while(1){
        int cur = ans.back().ff;
        int nxt = 0;
        for(int j = 0; j < n; ++j){
            nxt = max(nxt, cur - cur%p[j]+p[j]-1);
        }
        if(nxt <= cur)
            break;
        ans.pb({nxt, ans.back().ss+1});
        if(nxt > 1e7)
            break;
    }
    while(q--){
        int x;
        cin >> x;
        int id = lower_bound(all(ans), mp(x, -1))-ans.begin();
        if(id == ans.size())
            cout << "oo\n";
        else
            cout << ans[id].ss << '\n';
    }
    
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:47:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         if(id == ans.size())
      |            ~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 9 ms 768 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 19 ms 2680 KB Output is correct
6 Correct 1 ms 288 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 32 ms 4584 KB Output is correct
10 Correct 18 ms 1532 KB Output is correct
11 Correct 18 ms 1532 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 9 ms 384 KB Output is correct
14 Correct 12 ms 384 KB Output is correct
15 Correct 8 ms 768 KB Output is correct
16 Correct 9 ms 768 KB Output is correct
17 Correct 11 ms 768 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 10 ms 640 KB Output is correct
3 Correct 10 ms 768 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 8 ms 512 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 12 ms 768 KB Output is correct
10 Correct 10 ms 640 KB Output is correct
11 Correct 8 ms 512 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 8 ms 512 KB Output is correct
16 Correct 10 ms 640 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 12 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 640 KB Output is correct
2 Correct 15 ms 640 KB Output is correct
3 Correct 20 ms 640 KB Output is correct
4 Correct 23 ms 640 KB Output is correct
5 Correct 29 ms 888 KB Output is correct
6 Correct 26 ms 640 KB Output is correct
7 Correct 23 ms 888 KB Output is correct
8 Correct 16 ms 640 KB Output is correct
9 Correct 16 ms 640 KB Output is correct
10 Correct 8 ms 512 KB Output is correct
11 Correct 9 ms 384 KB Output is correct
12 Correct 10 ms 384 KB Output is correct
13 Correct 26 ms 856 KB Output is correct
14 Correct 44 ms 1772 KB Output is correct
15 Correct 11 ms 384 KB Output is correct
16 Correct 12 ms 384 KB Output is correct
17 Correct 10 ms 512 KB Output is correct
18 Correct 15 ms 640 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
20 Correct 20 ms 640 KB Output is correct
21 Correct 32 ms 1152 KB Output is correct
22 Correct 33 ms 896 KB Output is correct
23 Correct 29 ms 640 KB Output is correct
24 Correct 25 ms 640 KB Output is correct
25 Correct 26 ms 640 KB Output is correct
26 Correct 22 ms 640 KB Output is correct
27 Correct 24 ms 768 KB Output is correct
28 Correct 20 ms 640 KB Output is correct
29 Correct 32 ms 888 KB Output is correct
30 Correct 36 ms 888 KB Output is correct
31 Correct 20 ms 640 KB Output is correct
32 Correct 28 ms 640 KB Output is correct
33 Correct 22 ms 640 KB Output is correct
34 Correct 22 ms 888 KB Output is correct
35 Correct 20 ms 640 KB Output is correct
36 Correct 36 ms 896 KB Output is correct
37 Correct 34 ms 896 KB Output is correct
38 Correct 25 ms 640 KB Output is correct
39 Correct 24 ms 640 KB Output is correct
40 Correct 24 ms 640 KB Output is correct
41 Correct 22 ms 888 KB Output is correct
42 Correct 28 ms 760 KB Output is correct