# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
580432 |
2022-06-21T08:43:03 Z |
반딧불(#8355) |
Uplifting Excursion (BOI22_vault) |
C++17 |
|
310 ms |
4292 KB |
#include <bits/stdc++.h>
#ifndef TEST
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#endif
using namespace std;
typedef long long ll;
const ll LIM = 100000;
void imp(){
puts("impossible");
exit(0);
}
ll dq1[1000002];
ll dq2[1000002];
int fr, sz;
ll f(ll x, ll y, bool b){
if(b) return max(x, y);
return min(x, y);
}
void calculateMax(int n, ll* arr, int lim, vector<ll>& ret){
ret = vector<ll>(lim+1, -1e18);
ret[0] = 0;
vector<ll> tvec (lim+1, -1e18);
for(int i=1; i<=n; i++){
tvec.swap(ret);
for(int s=0; s<i; s++){
fr=sz=0;
for(int j=s, p=0; j<=lim; j+=i, p++){
ret[j] = max(ret[j], tvec[j]);
while(fr!=sz && dq2[fr] < p) fr++;
ll nf = tvec[j]-p;
while(fr!=sz && dq1[sz-1] < nf) sz--;
dq1[sz] = nf;
dq2[sz++] = p+arr[i];
ret[j] = max(ret[j], dq1[fr] + p);
}
}
}
}
void calculateMin(int n, ll* arr, int lim, vector<ll>& ret){
ret = vector<ll>(lim+1, 1e18);
ret[0] = 0;
vector<ll> tvec (lim+1, 1e18);
for(int i=1; i<=n; i++){
tvec.swap(ret);
for(int s=0; s<i; s++){
fr=sz=0;
for(int j=s, p=0; j<=lim; j+=i, p++){
ret[j] = min(ret[j], tvec[j]);
while(fr!=sz && dq2[fr] < p) fr++;
ll nf = tvec[j]-p;
while(fr!=sz && dq1[sz-1] > nf) sz--;
dq1[sz] = nf;
dq2[sz++] = p+arr[i];
ret[j] = min(ret[j], dq1[fr] + p);
}
}
}
}
int n;
ll k;
ll arr[302];
ll used[302];
ll rem[302];
vector<ll> DP, DP2;
ll ans = -1e18;
ll frontCnt;
int main(){
scanf("%lld %lld", &n, &k);
for(int i=0; i<n; i++) scanf("%lld", &arr[i]);
for(int i=0; i<=n; i++) scanf("%lld", &arr[i]);
if(k<=0) imp();
for(int i=0; i<=n; i++){
if(k >= arr[i]*i){
k -= arr[i]*i;
used[i] = arr[i];
rem[i] = 0;
}
else{
ll tmp = k/i;
used[i] = tmp;
rem[i] = arr[i]-tmp;
k -= tmp*i;
}
}
if(accumulate(rem, rem+n+1, 0LL) == 0) imp();
frontCnt = accumulate(used, used+n+1, 0LL);
calculateMax(n, rem, LIM, DP); /// �ִ�
calculateMin(n, used, LIM, DP2); /// �ּ�
for(ll i=k; i<=LIM; i++){
ll j = i-k;
ans = max(ans, frontCnt + DP[i] - DP2[j]);
}
if(ans <= 0) imp();
printf("%lld", ans);
}
Compilation message
vault.cpp: In function 'int main()':
vault.cpp:81:15: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
81 | scanf("%lld %lld", &n, &k);
| ~~~^ ~~
| | |
| | int*
| long long int*
| %d
vault.cpp:81:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
81 | scanf("%lld %lld", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
vault.cpp:82:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
82 | for(int i=0; i<n; i++) scanf("%lld", &arr[i]);
| ~~~~~^~~~~~~~~~~~~~~~~
vault.cpp:83:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
83 | for(int i=0; i<=n; i++) scanf("%lld", &arr[i]);
| ~~~~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
4164 KB |
Output is correct |
2 |
Correct |
40 ms |
4220 KB |
Output is correct |
3 |
Correct |
27 ms |
4228 KB |
Output is correct |
4 |
Correct |
33 ms |
4164 KB |
Output is correct |
5 |
Correct |
32 ms |
4164 KB |
Output is correct |
6 |
Correct |
27 ms |
4220 KB |
Output is correct |
7 |
Correct |
28 ms |
4224 KB |
Output is correct |
8 |
Correct |
26 ms |
4164 KB |
Output is correct |
9 |
Correct |
27 ms |
4220 KB |
Output is correct |
10 |
Correct |
38 ms |
4224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
4164 KB |
Output is correct |
2 |
Correct |
40 ms |
4220 KB |
Output is correct |
3 |
Correct |
27 ms |
4228 KB |
Output is correct |
4 |
Correct |
33 ms |
4164 KB |
Output is correct |
5 |
Correct |
32 ms |
4164 KB |
Output is correct |
6 |
Correct |
27 ms |
4220 KB |
Output is correct |
7 |
Correct |
28 ms |
4224 KB |
Output is correct |
8 |
Correct |
26 ms |
4164 KB |
Output is correct |
9 |
Correct |
27 ms |
4220 KB |
Output is correct |
10 |
Correct |
38 ms |
4224 KB |
Output is correct |
11 |
Incorrect |
4 ms |
4164 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
4164 KB |
Output is correct |
2 |
Correct |
40 ms |
4220 KB |
Output is correct |
3 |
Correct |
27 ms |
4228 KB |
Output is correct |
4 |
Correct |
33 ms |
4164 KB |
Output is correct |
5 |
Correct |
32 ms |
4164 KB |
Output is correct |
6 |
Correct |
27 ms |
4220 KB |
Output is correct |
7 |
Correct |
28 ms |
4224 KB |
Output is correct |
8 |
Correct |
26 ms |
4164 KB |
Output is correct |
9 |
Correct |
27 ms |
4220 KB |
Output is correct |
10 |
Correct |
38 ms |
4224 KB |
Output is correct |
11 |
Correct |
10 ms |
4220 KB |
Output is correct |
12 |
Correct |
33 ms |
4164 KB |
Output is correct |
13 |
Correct |
26 ms |
4228 KB |
Output is correct |
14 |
Correct |
30 ms |
4228 KB |
Output is correct |
15 |
Correct |
31 ms |
4164 KB |
Output is correct |
16 |
Correct |
26 ms |
4224 KB |
Output is correct |
17 |
Correct |
24 ms |
4224 KB |
Output is correct |
18 |
Correct |
26 ms |
4212 KB |
Output is correct |
19 |
Correct |
33 ms |
4228 KB |
Output is correct |
20 |
Correct |
29 ms |
4164 KB |
Output is correct |
21 |
Correct |
38 ms |
4216 KB |
Output is correct |
22 |
Correct |
49 ms |
4220 KB |
Output is correct |
23 |
Correct |
51 ms |
4164 KB |
Output is correct |
24 |
Correct |
45 ms |
4152 KB |
Output is correct |
25 |
Correct |
59 ms |
4220 KB |
Output is correct |
26 |
Correct |
61 ms |
4216 KB |
Output is correct |
27 |
Correct |
47 ms |
4220 KB |
Output is correct |
28 |
Correct |
56 ms |
4204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
4164 KB |
Output is correct |
2 |
Correct |
40 ms |
4220 KB |
Output is correct |
3 |
Correct |
27 ms |
4228 KB |
Output is correct |
4 |
Correct |
33 ms |
4164 KB |
Output is correct |
5 |
Correct |
32 ms |
4164 KB |
Output is correct |
6 |
Correct |
27 ms |
4220 KB |
Output is correct |
7 |
Correct |
28 ms |
4224 KB |
Output is correct |
8 |
Correct |
26 ms |
4164 KB |
Output is correct |
9 |
Correct |
27 ms |
4220 KB |
Output is correct |
10 |
Correct |
38 ms |
4224 KB |
Output is correct |
11 |
Correct |
10 ms |
4220 KB |
Output is correct |
12 |
Correct |
33 ms |
4164 KB |
Output is correct |
13 |
Correct |
26 ms |
4228 KB |
Output is correct |
14 |
Correct |
30 ms |
4228 KB |
Output is correct |
15 |
Correct |
31 ms |
4164 KB |
Output is correct |
16 |
Correct |
26 ms |
4224 KB |
Output is correct |
17 |
Correct |
24 ms |
4224 KB |
Output is correct |
18 |
Correct |
26 ms |
4212 KB |
Output is correct |
19 |
Correct |
33 ms |
4228 KB |
Output is correct |
20 |
Correct |
29 ms |
4164 KB |
Output is correct |
21 |
Correct |
38 ms |
4216 KB |
Output is correct |
22 |
Correct |
49 ms |
4220 KB |
Output is correct |
23 |
Correct |
51 ms |
4164 KB |
Output is correct |
24 |
Correct |
45 ms |
4152 KB |
Output is correct |
25 |
Correct |
59 ms |
4220 KB |
Output is correct |
26 |
Correct |
61 ms |
4216 KB |
Output is correct |
27 |
Correct |
47 ms |
4220 KB |
Output is correct |
28 |
Correct |
56 ms |
4204 KB |
Output is correct |
29 |
Correct |
10 ms |
4164 KB |
Output is correct |
30 |
Correct |
32 ms |
4164 KB |
Output is correct |
31 |
Correct |
30 ms |
4292 KB |
Output is correct |
32 |
Correct |
41 ms |
4160 KB |
Output is correct |
33 |
Correct |
33 ms |
4224 KB |
Output is correct |
34 |
Correct |
29 ms |
4224 KB |
Output is correct |
35 |
Correct |
24 ms |
4224 KB |
Output is correct |
36 |
Correct |
25 ms |
4220 KB |
Output is correct |
37 |
Correct |
27 ms |
4164 KB |
Output is correct |
38 |
Correct |
30 ms |
4216 KB |
Output is correct |
39 |
Correct |
41 ms |
4164 KB |
Output is correct |
40 |
Correct |
39 ms |
4212 KB |
Output is correct |
41 |
Correct |
48 ms |
4212 KB |
Output is correct |
42 |
Correct |
47 ms |
4164 KB |
Output is correct |
43 |
Correct |
50 ms |
4216 KB |
Output is correct |
44 |
Correct |
51 ms |
4208 KB |
Output is correct |
45 |
Correct |
59 ms |
4216 KB |
Output is correct |
46 |
Correct |
47 ms |
4164 KB |
Output is correct |
47 |
Correct |
72 ms |
4208 KB |
Output is correct |
48 |
Correct |
86 ms |
4212 KB |
Output is correct |
49 |
Correct |
103 ms |
4156 KB |
Output is correct |
50 |
Correct |
92 ms |
4176 KB |
Output is correct |
51 |
Correct |
111 ms |
4216 KB |
Output is correct |
52 |
Correct |
94 ms |
4204 KB |
Output is correct |
53 |
Correct |
85 ms |
4200 KB |
Output is correct |
54 |
Correct |
88 ms |
4220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
4164 KB |
Output is correct |
2 |
Correct |
40 ms |
4220 KB |
Output is correct |
3 |
Correct |
27 ms |
4228 KB |
Output is correct |
4 |
Correct |
33 ms |
4164 KB |
Output is correct |
5 |
Correct |
32 ms |
4164 KB |
Output is correct |
6 |
Correct |
27 ms |
4220 KB |
Output is correct |
7 |
Correct |
28 ms |
4224 KB |
Output is correct |
8 |
Correct |
26 ms |
4164 KB |
Output is correct |
9 |
Correct |
27 ms |
4220 KB |
Output is correct |
10 |
Correct |
38 ms |
4224 KB |
Output is correct |
11 |
Correct |
10 ms |
4220 KB |
Output is correct |
12 |
Correct |
33 ms |
4164 KB |
Output is correct |
13 |
Correct |
26 ms |
4228 KB |
Output is correct |
14 |
Correct |
30 ms |
4228 KB |
Output is correct |
15 |
Correct |
31 ms |
4164 KB |
Output is correct |
16 |
Correct |
26 ms |
4224 KB |
Output is correct |
17 |
Correct |
24 ms |
4224 KB |
Output is correct |
18 |
Correct |
26 ms |
4212 KB |
Output is correct |
19 |
Correct |
33 ms |
4228 KB |
Output is correct |
20 |
Correct |
29 ms |
4164 KB |
Output is correct |
21 |
Correct |
38 ms |
4216 KB |
Output is correct |
22 |
Correct |
49 ms |
4220 KB |
Output is correct |
23 |
Correct |
51 ms |
4164 KB |
Output is correct |
24 |
Correct |
45 ms |
4152 KB |
Output is correct |
25 |
Correct |
59 ms |
4220 KB |
Output is correct |
26 |
Correct |
61 ms |
4216 KB |
Output is correct |
27 |
Correct |
47 ms |
4220 KB |
Output is correct |
28 |
Correct |
56 ms |
4204 KB |
Output is correct |
29 |
Correct |
10 ms |
4164 KB |
Output is correct |
30 |
Correct |
32 ms |
4164 KB |
Output is correct |
31 |
Correct |
30 ms |
4292 KB |
Output is correct |
32 |
Correct |
41 ms |
4160 KB |
Output is correct |
33 |
Correct |
33 ms |
4224 KB |
Output is correct |
34 |
Correct |
29 ms |
4224 KB |
Output is correct |
35 |
Correct |
24 ms |
4224 KB |
Output is correct |
36 |
Correct |
25 ms |
4220 KB |
Output is correct |
37 |
Correct |
27 ms |
4164 KB |
Output is correct |
38 |
Correct |
30 ms |
4216 KB |
Output is correct |
39 |
Correct |
41 ms |
4164 KB |
Output is correct |
40 |
Correct |
39 ms |
4212 KB |
Output is correct |
41 |
Correct |
48 ms |
4212 KB |
Output is correct |
42 |
Correct |
47 ms |
4164 KB |
Output is correct |
43 |
Correct |
50 ms |
4216 KB |
Output is correct |
44 |
Correct |
51 ms |
4208 KB |
Output is correct |
45 |
Correct |
59 ms |
4216 KB |
Output is correct |
46 |
Correct |
47 ms |
4164 KB |
Output is correct |
47 |
Correct |
72 ms |
4208 KB |
Output is correct |
48 |
Correct |
86 ms |
4212 KB |
Output is correct |
49 |
Correct |
103 ms |
4156 KB |
Output is correct |
50 |
Correct |
92 ms |
4176 KB |
Output is correct |
51 |
Correct |
111 ms |
4216 KB |
Output is correct |
52 |
Correct |
94 ms |
4204 KB |
Output is correct |
53 |
Correct |
85 ms |
4200 KB |
Output is correct |
54 |
Correct |
88 ms |
4220 KB |
Output is correct |
55 |
Correct |
11 ms |
4164 KB |
Output is correct |
56 |
Correct |
32 ms |
4164 KB |
Output is correct |
57 |
Correct |
26 ms |
4164 KB |
Output is correct |
58 |
Correct |
32 ms |
4228 KB |
Output is correct |
59 |
Correct |
36 ms |
4228 KB |
Output is correct |
60 |
Correct |
27 ms |
4216 KB |
Output is correct |
61 |
Correct |
27 ms |
4164 KB |
Output is correct |
62 |
Correct |
26 ms |
4228 KB |
Output is correct |
63 |
Correct |
33 ms |
4164 KB |
Output is correct |
64 |
Correct |
34 ms |
4220 KB |
Output is correct |
65 |
Correct |
39 ms |
4164 KB |
Output is correct |
66 |
Correct |
41 ms |
4140 KB |
Output is correct |
67 |
Correct |
59 ms |
4136 KB |
Output is correct |
68 |
Correct |
51 ms |
4164 KB |
Output is correct |
69 |
Correct |
53 ms |
4164 KB |
Output is correct |
70 |
Correct |
58 ms |
4216 KB |
Output is correct |
71 |
Correct |
43 ms |
4156 KB |
Output is correct |
72 |
Correct |
49 ms |
4156 KB |
Output is correct |
73 |
Correct |
82 ms |
4164 KB |
Output is correct |
74 |
Correct |
72 ms |
4200 KB |
Output is correct |
75 |
Correct |
99 ms |
4204 KB |
Output is correct |
76 |
Correct |
81 ms |
4212 KB |
Output is correct |
77 |
Correct |
96 ms |
4212 KB |
Output is correct |
78 |
Correct |
95 ms |
4204 KB |
Output is correct |
79 |
Correct |
87 ms |
4212 KB |
Output is correct |
80 |
Correct |
93 ms |
4156 KB |
Output is correct |
81 |
Correct |
280 ms |
4284 KB |
Output is correct |
82 |
Correct |
294 ms |
4212 KB |
Output is correct |
83 |
Correct |
288 ms |
4208 KB |
Output is correct |
84 |
Correct |
310 ms |
4204 KB |
Output is correct |
85 |
Correct |
213 ms |
4208 KB |
Output is correct |
86 |
Correct |
214 ms |
4156 KB |
Output is correct |
87 |
Correct |
295 ms |
4200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4164 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |