답안 #256245

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
256245 2020-08-02T11:59:12 Z shayan_p Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
413 ms 144668 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 = 1e7 + 10, mod = 1e9 + 7, inf = 1e9 + 10; //////

int a[maxn], dp[MAX];
int ext[MAX];

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));
	for(int j = 0; j < MAX; j+= a[i])
	    ext[j] = max(ext[j], j + a[i]);
    }
    vector<int> vec;
    int pt = 0;
    vec.PB(0);
    for(int i = 1; i < lm; i++){
	while(pt < sz(vec) && ext[vec[pt]] <= i)
	    pt++;
	dp[i] = 1 + dp[ vec[pt] ];
	if(ext[i] > i)
	    vec.PB(i);
    }
    while(q--){
	int x;
	cin >> x;
	if(x >= lm)
	    cout << "oo\n";
	else
	    cout << dp[x] << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 39544 KB Output is correct
2 Correct 182 ms 107292 KB Output is correct
3 Correct 56 ms 41460 KB Output is correct
4 Correct 108 ms 81764 KB Output is correct
5 Correct 150 ms 89152 KB Output is correct
6 Correct 35 ms 39544 KB Output is correct
7 Correct 55 ms 41460 KB Output is correct
8 Correct 64 ms 46448 KB Output is correct
9 Correct 208 ms 110876 KB Output is correct
10 Correct 233 ms 144156 KB Output is correct
11 Correct 207 ms 106132 KB Output is correct
12 Correct 98 ms 82028 KB Output is correct
13 Correct 301 ms 140700 KB Output is correct
14 Correct 316 ms 140828 KB Output is correct
15 Correct 183 ms 106396 KB Output is correct
16 Correct 169 ms 107164 KB Output is correct
17 Correct 158 ms 89052 KB Output is correct
18 Correct 108 ms 81764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 85468 KB Output is correct
2 Correct 164 ms 93524 KB Output is correct
3 Correct 350 ms 140700 KB Output is correct
4 Correct 183 ms 94656 KB Output is correct
5 Correct 271 ms 110492 KB Output is correct
6 Correct 160 ms 102300 KB Output is correct
7 Correct 132 ms 85468 KB Output is correct
8 Correct 197 ms 92864 KB Output is correct
9 Correct 301 ms 144412 KB Output is correct
10 Correct 334 ms 140700 KB Output is correct
11 Correct 345 ms 141084 KB Output is correct
12 Correct 219 ms 108572 KB Output is correct
13 Correct 131 ms 89560 KB Output is correct
14 Correct 180 ms 94656 KB Output is correct
15 Correct 300 ms 141736 KB Output is correct
16 Correct 162 ms 93536 KB Output is correct
17 Correct 306 ms 141096 KB Output is correct
18 Correct 303 ms 143900 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 315 ms 141340 KB Output is correct
2 Correct 362 ms 140816 KB Output is correct
3 Correct 376 ms 140992 KB Output is correct
4 Correct 269 ms 110888 KB Output is correct
5 Correct 195 ms 91220 KB Output is correct
6 Correct 334 ms 142880 KB Output is correct
7 Correct 329 ms 107804 KB Output is correct
8 Correct 312 ms 141476 KB Output is correct
9 Correct 305 ms 141344 KB Output is correct
10 Correct 267 ms 106280 KB Output is correct
11 Correct 239 ms 102172 KB Output is correct
12 Correct 288 ms 142880 KB Output is correct
13 Correct 346 ms 141852 KB Output is correct
14 Correct 253 ms 143260 KB Output is correct
15 Correct 315 ms 141092 KB Output is correct
16 Correct 361 ms 140828 KB Output is correct
17 Correct 291 ms 111260 KB Output is correct
18 Correct 354 ms 140832 KB Output is correct
19 Correct 144 ms 95552 KB Output is correct
20 Correct 368 ms 140852 KB Output is correct
21 Correct 266 ms 141980 KB Output is correct
22 Correct 370 ms 140828 KB Output is correct
23 Correct 199 ms 90820 KB Output is correct
24 Correct 155 ms 86996 KB Output is correct
25 Correct 303 ms 109592 KB Output is correct
26 Correct 251 ms 110876 KB Output is correct
27 Correct 391 ms 140928 KB Output is correct
28 Correct 179 ms 93632 KB Output is correct
29 Correct 395 ms 144028 KB Output is correct
30 Correct 323 ms 112164 KB Output is correct
31 Correct 205 ms 94528 KB Output is correct
32 Correct 224 ms 107068 KB Output is correct
33 Correct 133 ms 86368 KB Output is correct
34 Correct 292 ms 107932 KB Output is correct
35 Correct 189 ms 94400 KB Output is correct
36 Correct 413 ms 140960 KB Output is correct
37 Correct 215 ms 91220 KB Output is correct
38 Correct 361 ms 142748 KB Output is correct
39 Correct 195 ms 90964 KB Output is correct
40 Correct 332 ms 144668 KB Output is correct
41 Correct 267 ms 111004 KB Output is correct
42 Correct 372 ms 140700 KB Output is correct