# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
31850 | ToMo01 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 73 ms | 66244 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*input
2 2
2 3
5
6
*/
#include <bits/stdc++.h>
using namespace std;
const int N = 10000007;
int cost[N], p[100007], n, Q;
vector<pair<int, int> > v;
int main(){
iostream::sync_with_stdio(false); cin.tie(0);
cin >> n >> Q;
for(int i = 1; i <= n; ++i)
cin >> p[i];
sort(p + 1, p + n + 1);
for(int i = p[n] - 1; i > 0; --i)
cost[i] = 1;
for(int i = 1; i <= n; ++i)
v.push_back({p[i], i});
int l = 0;
for(int i = 1; i < N; ++i){
if(cost[i] == 1) continue;
while(v[l].first + p[v[l].second] - 1 < i) v.push_back({v[l].first + p[v[l].second], v[l++].second});
if(v[l].first < i) cost[i] = cost[v[l].first] + 1;
else cost[i] = N;
}
while(Q--){
int x; cin >> x;
if(cost[x] == N) cout << "oo\n";
else cout << cost[x] << "\n";
}
}
컴파일 시 표준 에러 (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... |