답안 #256236

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256236 2020-08-02T11:48:27 Z shayan_p Brunhilda’s Birthday (BOI13_brunhilda) C++14
20 / 100
42 ms 12652 KB
// And you curse yourself for things you never done

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const int maxn = 1e5 + 10, MAX = 1e4 + 10, mod = 1e9 + 7, inf = 1e9 + 10; //////

int a[maxn], dp[MAX];
set<pii> st;
priority_queue<pii, vector<pii>, greater<pii> > pq;
vector<int> vec;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();

    int n, q;
    cin >> n >> q;
    int lm = 1;
    for(int i = 0; i < n; i++){
	cin >> a[i];
        lm = min(1ll * lm * a[i], ll(MAX));
	pq.push({0, a[i]});
	st.insert({1, a[i]});
    }
    for(int i = 0; i < lm; i++){
	vec.clear();
	while(!pq.empty() && pq.top().F == i){
	    int p = pq.top().S;
	    vec.PB(p);
	    pq.pop();
	    st.erase({dp[i-p] + 1, p});
	}
	if(i > 0)
	    assert(sz(st)), dp[i] = st.begin()->F;
	for(int x : vec){
	    st.insert({dp[i] + 1, x});
	    pq.push({i + x, x});
	}
    }
    while(q--){
	int x;
	cin >> x;
	if(x >= lm)
	    cout << "oo\n";
	else
	    cout << dp[x] << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 8 ms 512 KB Output is correct
14 Correct 11 ms 512 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 2 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 38 ms 11628 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 30 ms 9068 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 2 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 21 ms 6776 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 5 ms 2048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 31 ms 9328 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 28 ms 9076 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 17 ms 5368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 2 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 2 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 17 ms 5624 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 38 ms 11628 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 2 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 41 ms 12652 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 21 ms 6648 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 23 ms 6904 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 21 ms 6640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 2 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 42 ms 12396 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 4 ms 1536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 41 ms 12556 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 20 ms 6512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 21 ms 6640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 3 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 3 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 12 ms 4220 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Incorrect 20 ms 1408 KB Output isn't correct
15 Runtime error 3 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 4 ms 1536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 19 ms 6008 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 21 ms 6904 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 3 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 22 ms 6512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Incorrect 22 ms 1280 KB Output isn't correct
22 Runtime error 42 ms 12524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 12 ms 4220 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 1 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 2 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 2 ms 1128 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 41 ms 12548 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 2 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 40 ms 12524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 29 ms 8940 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Runtime error 2 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
32 Runtime error 2 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
33 Runtime error 1 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
34 Runtime error 41 ms 12524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
35 Runtime error 2 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
36 Runtime error 39 ms 11324 KB Execution killed with signal 11 (could be triggered by violating memory limits)
37 Runtime error 42 ms 12396 KB Execution killed with signal 11 (could be triggered by violating memory limits)
38 Runtime error 4 ms 1536 KB Execution killed with signal 11 (could be triggered by violating memory limits)
39 Runtime error 3 ms 768 KB Execution killed with signal 11 (could be triggered by violating memory limits)
40 Runtime error 5 ms 1792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 41 ms 12524 KB Execution killed with signal 11 (could be triggered by violating memory limits)
42 Runtime error 2 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)