이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define el '\n'
#define ld long double
const int maxn=1e5+1;
ll a[maxn],n,m,q,p,oo,ans;
ll t;
bool ok;
void check(){
t=1;
ok=0;
for(int i=0;i<m;++i){
if(t*a[i]<t || t*a[i]>oo){
ok=1;
return;
}
t=t*a[i];
}
}
void sol(){
ans=n/a[m-1];
ans*=2;
if(n%a[m-1]!=0) ans++;
cout << ans;
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin >> m >> q;
for(int i=0;i<m;++i) cin >> a[i];
sort(a,a+m);
oo=1e7;
check();
while(q--){
cin >> n;
if(ok){
sol();
} else {
if(n>=t){
cout << "oo";
} else {
sol();
}
}
cout << el;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |