이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXM = 100007, MAXA = 1000007, MAXV = 10000007;
int Q, M;
int P[MAXM], R[MAXA], last;
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> M >> Q;
for (int i = 0; i < M; ++i) cin >> P[i];
R[last = 0] = 0;
while (R[last] < MAXV) {
int nxt = -1;
for (int i = 0; i < M; ++i) nxt = max(nxt, R[last] - (R[last] % P[i]) + P[i] - 1);
if (nxt <= R[last]) break;
R[++last] = nxt;
}
for (int q = 0; q < Q; ++q) {
int x;
cin >> x;
if (x > R[last]) cout << "oo\n";
else cout << lower_bound(R, R + last + 1, x) - R << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |