제출 #1304529

#제출 시각아이디문제언어결과실행 시간메모리
1304529jeremBrunhilda’s Birthday (BOI13_brunhilda)C++20
20 / 100
1099 ms39936 KiB
#include<bits/stdc++.h> using namespace std; const int maxn = 1e7+7, maxn2 = 1e5 + 5; int n, m, q, reszta; int dp[maxn], pier[maxn2]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); for(int i = 1; i <= 1e7; i++) { dp[i] = 1e9; } cin >> m >> q; for(int i = 1; i <= m; i++) { cin >> pier[i]; } dp[0] = 0; for(int i = 1; i <= 1e4; i++) { // cout << " i " << i << endl; for(int j = m; j >= 1; j--) { if(i >= pier[j]) { reszta = (i % pier[j]); // cout << " reszta " << reszta << endl; dp[i] = min(dp[i], 1 + dp[i-reszta]); } else { dp[i] = 1; break; } } } for(int i = 0; i < q; i++) { cin >> n; if(n > 1e4){while(true){reszta++;}} if(dp[n] >= 1e9) { cout << "oo" << '\n'; } else { cout << dp[n] << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...