Submission #283110

# Submission time Handle Problem Language Result Execution time Memory
283110 2020-08-25T10:06:30 Z egekabas Brunhilda’s Birthday (BOI13_brunhilda) C++14
44.7619 / 100
58 ms 4588 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 || nxt > 1e7)
            break;
        ans.pb({nxt, ans.back().ss+1});
    }
    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:45: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]
   45 |         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 7 ms 384 KB Output is correct
5 Correct 20 ms 2552 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 512 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 33 ms 4588 KB Output is correct
10 Correct 18 ms 1532 KB Output is correct
11 Correct 18 ms 1532 KB Output is correct
12 Correct 6 ms 384 KB Output is correct
13 Correct 10 ms 384 KB Output is correct
14 Correct 11 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 12 ms 768 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Incorrect 11 ms 768 KB Output isn't correct
3 Correct 10 ms 640 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 Incorrect 2 ms 384 KB Output isn't correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 26 ms 640 KB Output is correct
10 Correct 11 ms 640 KB Output is correct
11 Incorrect 20 ms 512 KB Output isn't 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 Incorrect 12 ms 768 KB Output isn't correct
17 Correct 7 ms 416 KB Output is correct
18 Incorrect 14 ms 768 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 640 KB Output isn't correct
2 Incorrect 32 ms 632 KB Output isn't correct
3 Correct 21 ms 1024 KB Output is correct
4 Incorrect 45 ms 640 KB Output isn't correct
5 Incorrect 46 ms 1016 KB Output isn't correct
6 Incorrect 26 ms 1152 KB Output isn't correct
7 Correct 23 ms 768 KB Output is correct
8 Incorrect 16 ms 640 KB Output isn't correct
9 Incorrect 18 ms 640 KB Output isn't correct
10 Incorrect 8 ms 384 KB Output isn't correct
11 Incorrect 9 ms 384 KB Output isn't correct
12 Incorrect 20 ms 384 KB Output isn't correct
13 Correct 25 ms 1152 KB Output is correct
14 Correct 58 ms 2416 KB Output is correct
15 Incorrect 11 ms 640 KB Output isn't correct
16 Incorrect 15 ms 640 KB Output isn't correct
17 Incorrect 11 ms 896 KB Output isn't correct
18 Incorrect 15 ms 1152 KB Output isn't correct
19 Incorrect 6 ms 640 KB Output isn't correct
20 Correct 20 ms 1408 KB Output is correct
21 Incorrect 32 ms 1920 KB Output isn't correct
22 Incorrect 36 ms 2296 KB Output isn't correct
23 Incorrect 26 ms 1664 KB Output isn't correct
24 Incorrect 26 ms 1408 KB Output isn't correct
25 Incorrect 28 ms 1408 KB Output isn't correct
26 Incorrect 23 ms 1280 KB Output isn't correct
27 Correct 57 ms 1784 KB Output is correct
28 Incorrect 25 ms 1400 KB Output isn't correct
29 Incorrect 32 ms 2252 KB Output isn't correct
30 Incorrect 41 ms 2144 KB Output isn't correct
31 Incorrect 20 ms 1280 KB Output isn't correct
32 Incorrect 24 ms 1400 KB Output isn't correct
33 Incorrect 21 ms 1280 KB Output isn't correct
34 Correct 23 ms 1792 KB Output is correct
35 Incorrect 21 ms 1408 KB Output isn't correct
36 Incorrect 33 ms 2176 KB Output isn't correct
37 Incorrect 31 ms 2316 KB Output isn't correct
38 Incorrect 26 ms 1428 KB Output isn't correct
39 Incorrect 25 ms 1408 KB Output isn't correct
40 Incorrect 25 ms 1408 KB Output isn't correct
41 Correct 23 ms 1784 KB Output is correct
42 Incorrect 29 ms 1528 KB Output isn't correct