# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
588660 | 2022-07-03T19:32:47 Z | peuch | Uplifting Excursion (BOI22_vault) | C++17 | 5000 ms | 14796 KB |
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("avx,avx2,fma") const long long MAXN = 101; const long long MAXA = 101 * 100 * 101 - 1e5; const long long INF = 1e18; const long long HALF = MAXA / 2; long long m; long long l; long long v[2 * MAXN]; long long dp[2][MAXA]; int main(){ scanf("%lld %lld", &m, &l); long long sum = 0; long long cnt = 0; vector<pair<long long, long long> > moedas; for(long long i = -m; i <= m; i++){ scanf("%lld", &v[i + m]); sum += v[i + m] * i; cnt += v[i + m]; long long aux = v[i + m]; long long tam = 1; while(aux > 0){ moedas.push_back(make_pair(i * tam, tam)); aux--; if(aux % 2 == 1){ moedas.push_back(make_pair(i * tam, tam)); aux--; } aux /= 2; tam *= 2; } } if(l + HALF >= MAXA || l + HALF < 0){ printf("impossible\n"); return 0; } for(long long j = 0; j < MAXA; j++) dp[1][j] = INF; dp[1][HALF] = 0; for(auto val : moedas){ swap(dp[0], dp[1]); for(long long j = max(0LL, val.first); j < min((long long)MAXA, MAXA - val.first); j++){ dp[1][j] = dp[0][j]; if(j - val.first < MAXA && j - val.first >= 0) dp[1][j] = min(dp[1][j], dp[0][j - val.first] + val.second); } } if(dp[1][sum - l + HALF] == INF) printf("impossible\n"); else printf("%lld\n", cnt - dp[1][sum - l + HALF]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 14700 KB | Output is correct |
2 | Correct | 38 ms | 14676 KB | Output is correct |
3 | Correct | 24 ms | 14676 KB | Output is correct |
4 | Correct | 154 ms | 14676 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 2659 ms | 14712 KB | Output is correct |
7 | Correct | 1166 ms | 14704 KB | Output is correct |
8 | Correct | 2654 ms | 14708 KB | Output is correct |
9 | Correct | 3363 ms | 14720 KB | Output is correct |
10 | Correct | 112 ms | 14680 KB | Output is correct |
11 | Correct | 106 ms | 14684 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 14700 KB | Output is correct |
2 | Correct | 38 ms | 14676 KB | Output is correct |
3 | Correct | 24 ms | 14676 KB | Output is correct |
4 | Correct | 154 ms | 14676 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 2659 ms | 14712 KB | Output is correct |
7 | Correct | 1166 ms | 14704 KB | Output is correct |
8 | Correct | 2654 ms | 14708 KB | Output is correct |
9 | Correct | 3363 ms | 14720 KB | Output is correct |
10 | Correct | 112 ms | 14680 KB | Output is correct |
11 | Correct | 106 ms | 14684 KB | Output is correct |
12 | Correct | 49 ms | 14676 KB | Output is correct |
13 | Correct | 40 ms | 14676 KB | Output is correct |
14 | Correct | 24 ms | 14704 KB | Output is correct |
15 | Correct | 158 ms | 14796 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2709 ms | 14708 KB | Output is correct |
18 | Correct | 1183 ms | 14700 KB | Output is correct |
19 | Correct | 2622 ms | 14712 KB | Output is correct |
20 | Correct | 3445 ms | 14716 KB | Output is correct |
21 | Correct | 93 ms | 14676 KB | Output is correct |
22 | Correct | 101 ms | 14680 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Execution timed out | 5065 ms | 14676 KB | Time limit exceeded |
25 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 14676 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 14676 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 14676 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 14700 KB | Output is correct |
2 | Correct | 38 ms | 14676 KB | Output is correct |
3 | Correct | 24 ms | 14676 KB | Output is correct |
4 | Correct | 154 ms | 14676 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 2659 ms | 14712 KB | Output is correct |
7 | Correct | 1166 ms | 14704 KB | Output is correct |
8 | Correct | 2654 ms | 14708 KB | Output is correct |
9 | Correct | 3363 ms | 14720 KB | Output is correct |
10 | Correct | 112 ms | 14680 KB | Output is correct |
11 | Correct | 106 ms | 14684 KB | Output is correct |
12 | Correct | 159 ms | 14676 KB | Output is correct |
13 | Incorrect | 0 ms | 212 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 14676 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 14700 KB | Output is correct |
2 | Correct | 38 ms | 14676 KB | Output is correct |
3 | Correct | 24 ms | 14676 KB | Output is correct |
4 | Correct | 154 ms | 14676 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 2659 ms | 14712 KB | Output is correct |
7 | Correct | 1166 ms | 14704 KB | Output is correct |
8 | Correct | 2654 ms | 14708 KB | Output is correct |
9 | Correct | 3363 ms | 14720 KB | Output is correct |
10 | Correct | 112 ms | 14680 KB | Output is correct |
11 | Correct | 106 ms | 14684 KB | Output is correct |
12 | Correct | 49 ms | 14676 KB | Output is correct |
13 | Correct | 40 ms | 14676 KB | Output is correct |
14 | Correct | 24 ms | 14704 KB | Output is correct |
15 | Correct | 158 ms | 14796 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2709 ms | 14708 KB | Output is correct |
18 | Correct | 1183 ms | 14700 KB | Output is correct |
19 | Correct | 2622 ms | 14712 KB | Output is correct |
20 | Correct | 3445 ms | 14716 KB | Output is correct |
21 | Correct | 93 ms | 14676 KB | Output is correct |
22 | Correct | 101 ms | 14680 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Execution timed out | 5065 ms | 14676 KB | Time limit exceeded |
25 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 14676 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 47 ms | 14700 KB | Output is correct |
2 | Correct | 38 ms | 14676 KB | Output is correct |
3 | Correct | 24 ms | 14676 KB | Output is correct |
4 | Correct | 154 ms | 14676 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 2659 ms | 14712 KB | Output is correct |
7 | Correct | 1166 ms | 14704 KB | Output is correct |
8 | Correct | 2654 ms | 14708 KB | Output is correct |
9 | Correct | 3363 ms | 14720 KB | Output is correct |
10 | Correct | 112 ms | 14680 KB | Output is correct |
11 | Correct | 106 ms | 14684 KB | Output is correct |
12 | Correct | 49 ms | 14676 KB | Output is correct |
13 | Correct | 40 ms | 14676 KB | Output is correct |
14 | Correct | 24 ms | 14704 KB | Output is correct |
15 | Correct | 158 ms | 14796 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 2709 ms | 14708 KB | Output is correct |
18 | Correct | 1183 ms | 14700 KB | Output is correct |
19 | Correct | 2622 ms | 14712 KB | Output is correct |
20 | Correct | 3445 ms | 14716 KB | Output is correct |
21 | Correct | 93 ms | 14676 KB | Output is correct |
22 | Correct | 101 ms | 14680 KB | Output is correct |
23 | Correct | 0 ms | 340 KB | Output is correct |
24 | Execution timed out | 5065 ms | 14676 KB | Time limit exceeded |
25 | Halted | 0 ms | 0 KB | - |