Submission #850581

# Submission time Handle Problem Language Result Execution time Memory
850581 2023-09-17T01:34:57 Z NK_ Brunhilda’s Birthday (BOI13_brunhilda) C++17
100 / 100
24 ms 3284 KB
// Success consists of going from failure to failure without loss of enthusiasm
#include <bits/stdc++.h>
 
using namespace std;
 
#define nl '\n'
#define pb push_back
#define pf push_front
 
#define mp make_pair
#define f first
#define s second
#define sz(x) int(x.size())
 
template<class T> using V = vector<T>;
using pi = pair<int, int>;
using vi = V<int>;
using vpi = V<pi>;
 
using ll = long long;
using pl = pair<ll, ll>;
using vpl = V<pl>;
using vl = V<ll>;
 
using db = long double;
 
template<class T> using pq = priority_queue<T, V<T>, greater<T>>;
 
const int MOD = 1e9 + 7;
const ll INFL = ll(1e17);
const int LG = 18;

const int MX = 1e7+7;

int main() {
	cin.tie(0)->sync_with_stdio(0);

	int N, Q; cin >> N >> Q;
	vi A(N); for(auto& x : A) cin >> x;

	vi q(Q); for(auto& x : q) cin >> x;

	int mx = *max_element(begin(q), end(q));

	vi C(N, -1);
	vi X = {0}; int cur = 1;
	while(cur <= mx) {
		int ncur = 0;
		for(int i = 0; i < N; i++) {
			if (C[i] < cur) C[i] = ((cur + A[i] - 1) / A[i]) * A[i];
			// cout << i << " " << C[i] << endl;
			ncur = max(ncur, C[i]);
		}

		if (cur == ncur) break;

		// cout << ncur << endl;
		X.pb(ncur - 1);
		cur = ncur;
	}


	for(auto x : q) {
		auto it = lower_bound(begin(X), end(X), x);
		if (it == end(X)) cout << "oo" << nl;
		else cout << int(it - begin(X)) << nl;
	}

	exit(0-0);
} 
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 0 ms 456 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 636 KB Output is correct
2 Correct 7 ms 1884 KB Output is correct
3 Correct 6 ms 1368 KB Output is correct
4 Correct 2 ms 464 KB Output is correct
5 Correct 4 ms 1120 KB Output is correct
6 Correct 1 ms 352 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 5 ms 1484 KB Output is correct
10 Correct 6 ms 1372 KB Output is correct
11 Correct 7 ms 936 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 2 ms 344 KB Output is correct
15 Correct 4 ms 864 KB Output is correct
16 Correct 7 ms 1748 KB Output is correct
17 Correct 6 ms 352 KB Output is correct
18 Correct 9 ms 1744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 2052 KB Output is correct
2 Correct 11 ms 1372 KB Output is correct
3 Correct 13 ms 1884 KB Output is correct
4 Correct 16 ms 1656 KB Output is correct
5 Correct 20 ms 3164 KB Output is correct
6 Correct 18 ms 1748 KB Output is correct
7 Correct 16 ms 2640 KB Output is correct
8 Correct 11 ms 1668 KB Output is correct
9 Correct 12 ms 1624 KB Output is correct
10 Correct 6 ms 604 KB Output is correct
11 Correct 7 ms 756 KB Output is correct
12 Correct 9 ms 600 KB Output is correct
13 Correct 15 ms 2104 KB Output is correct
14 Correct 24 ms 2232 KB Output is correct
15 Correct 10 ms 1112 KB Output is correct
16 Correct 9 ms 860 KB Output is correct
17 Correct 8 ms 1116 KB Output is correct
18 Correct 11 ms 1516 KB Output is correct
19 Correct 5 ms 600 KB Output is correct
20 Correct 13 ms 1884 KB Output is correct
21 Correct 22 ms 2212 KB Output is correct
22 Correct 22 ms 3152 KB Output is correct
23 Correct 18 ms 2384 KB Output is correct
24 Correct 17 ms 1828 KB Output is correct
25 Correct 21 ms 1880 KB Output is correct
26 Correct 17 ms 1624 KB Output is correct
27 Correct 16 ms 2644 KB Output is correct
28 Correct 13 ms 1872 KB Output is correct
29 Correct 22 ms 3148 KB Output is correct
30 Correct 22 ms 2648 KB Output is correct
31 Correct 15 ms 1628 KB Output is correct
32 Correct 17 ms 1832 KB Output is correct
33 Correct 14 ms 1628 KB Output is correct
34 Correct 15 ms 2504 KB Output is correct
35 Correct 14 ms 1884 KB Output is correct
36 Correct 22 ms 3156 KB Output is correct
37 Correct 20 ms 3284 KB Output is correct
38 Correct 18 ms 1876 KB Output is correct
39 Correct 17 ms 1884 KB Output is correct
40 Correct 17 ms 1884 KB Output is correct
41 Correct 14 ms 2632 KB Output is correct
42 Correct 19 ms 1928 KB Output is correct