# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
30899 | Navick | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 1000 ms | 80144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define F first
#define S second
#define pii pair<int, int>
#define pb push_back
using namespace std;
typedef long long ll;
typedef long double ld;
const int N = 1e7 + 10, INF = 1e9;
int dp[N], p[N];
int main(){
int m, q; scanf("%d %d", &m, &q);
for(int i=0; i<m; i++)
scanf("%d", p + i);
for(int i=1; i<N; i++){
//dp[i] ?!
int mr = 0;
for(int j=m - 1; j>=0 && mr < p[j]; j--)
mr = max(mr, i % p[j]);
if(mr == 0){
dp[i] = 0;
break;
}
else dp[i] = dp[i - mr] + 1;
}
for(int i=0; i<q; i++){
int n; scanf("%d", &n);
if(dp[n] == 0)
printf("oo\n");
else printf("%d\n", dp[n]);
}
}
Compilation message (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... |