# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1126016 | KasymK | Brunhilda’s Birthday (BOI13_brunhilda) | C++20 | 341 ms | 79248 KiB |
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i)
#define wr puts("----------------")
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
const int N = 1e5+5;
const int M = 1e7+5;
int p[N], ad[M], dp[M];
int main(){
// freopen("file.txt", "r", stdin);
int m, q;
scanf("%d%d", &m, &q);
for(int i = 1; i <= m; ++i){
scanf("%d", p+i);
for(int j = p[i]; j<M-3; j+=p[i])
ad[j-1]=p[i]-1;
umax(ad[M-5], (M-5)%p[i]);
}
for(int i = M-5; i >= 1; --i)
umax(ad[i], ad[i+1]-1);
for(int i = 1; i < M-4; ++i){
dp[i]=dp[i-ad[i]];
if(ad[i]!=0 and ~dp[i])
dp[i]++;
else
dp[i]=-1;
}
while(q--){
int x;
scanf("%d", &x);
if(~dp[x]){
printf("%d\n", dp[x]);
continue;
}
puts("oo");
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |