답안 #1026742

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1026742 2024-07-18T10:15:33 Z gyg Uplifting Excursion (BOI22_vault) C++17
5 / 100
5000 ms 8264 KB
#pragma GCC optimize("O3", "Ofast", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>    
using namespace std;
#define int long long
const int OFFSET = 5e5, INF = 1e9;
 
int n, tar;
unordered_map<int, int> t;
 
array<int, 2 * OFFSET + 5> dp;
void comp() {
    fill(dp.begin(), dp.end(), -INF);
    dp[OFFSET] = 0;
    for (int x = -n; x <= n; x++) {
        for (int i = 1; i <= t[x]; i++) {
            if (x >= 0) {
                for (int y = OFFSET; y >= -OFFSET; y--)
                    if (-OFFSET <= y - x && y - x <= OFFSET) dp[y + OFFSET] = max(dp[y + OFFSET], dp[y - x + OFFSET] + 1);
            } else {
                for (int y = -OFFSET; y <= OFFSET; y++)
                    if (-OFFSET <= y - x && y - x <= OFFSET) dp[y + OFFSET] = max(dp[y + OFFSET], dp[y - x + OFFSET] + 1);
            }

        }
    }
}
 
signed main() {
    // freopen("vault.in", "r", stdin);
    cin >> n >> tar;
    if (tar < -OFFSET || tar > OFFSET) { cout << "impossible" << '\n'; exit(0); }
    for (int i = -n; i <= n; i++) cin >> t[i];
 
    comp();
 
    cout << ((dp[tar + OFFSET] < 0) ? "impossible" : to_string(dp[tar + OFFSET])) << '\n';
    
}
 
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8024 KB Output is correct
2 Correct 7 ms 8260 KB Output is correct
3 Correct 4 ms 8256 KB Output is correct
4 Correct 35 ms 8028 KB Output is correct
5 Correct 0 ms 408 KB Output is correct
6 Correct 1704 ms 8240 KB Output is correct
7 Correct 652 ms 8028 KB Output is correct
8 Correct 1641 ms 8248 KB Output is correct
9 Correct 3006 ms 8244 KB Output is correct
10 Correct 64 ms 8024 KB Output is correct
11 Correct 48 ms 8028 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8024 KB Output is correct
2 Correct 7 ms 8260 KB Output is correct
3 Correct 4 ms 8256 KB Output is correct
4 Correct 35 ms 8028 KB Output is correct
5 Correct 0 ms 408 KB Output is correct
6 Correct 1704 ms 8240 KB Output is correct
7 Correct 652 ms 8028 KB Output is correct
8 Correct 1641 ms 8248 KB Output is correct
9 Correct 3006 ms 8244 KB Output is correct
10 Correct 64 ms 8024 KB Output is correct
11 Correct 48 ms 8028 KB Output is correct
12 Correct 8 ms 8028 KB Output is correct
13 Correct 6 ms 8264 KB Output is correct
14 Correct 5 ms 8028 KB Output is correct
15 Correct 34 ms 8244 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1760 ms 8028 KB Output is correct
18 Correct 664 ms 8028 KB Output is correct
19 Correct 1636 ms 8240 KB Output is correct
20 Correct 3062 ms 8244 KB Output is correct
21 Correct 64 ms 8028 KB Output is correct
22 Correct 54 ms 8028 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Execution timed out 5098 ms 8028 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 8028 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 8028 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 8028 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8024 KB Output is correct
2 Correct 7 ms 8260 KB Output is correct
3 Correct 4 ms 8256 KB Output is correct
4 Correct 35 ms 8028 KB Output is correct
5 Correct 0 ms 408 KB Output is correct
6 Correct 1704 ms 8240 KB Output is correct
7 Correct 652 ms 8028 KB Output is correct
8 Correct 1641 ms 8248 KB Output is correct
9 Correct 3006 ms 8244 KB Output is correct
10 Correct 64 ms 8024 KB Output is correct
11 Correct 48 ms 8028 KB Output is correct
12 Correct 38 ms 8028 KB Output is correct
13 Incorrect 1 ms 348 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 8028 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8024 KB Output is correct
2 Correct 7 ms 8260 KB Output is correct
3 Correct 4 ms 8256 KB Output is correct
4 Correct 35 ms 8028 KB Output is correct
5 Correct 0 ms 408 KB Output is correct
6 Correct 1704 ms 8240 KB Output is correct
7 Correct 652 ms 8028 KB Output is correct
8 Correct 1641 ms 8248 KB Output is correct
9 Correct 3006 ms 8244 KB Output is correct
10 Correct 64 ms 8024 KB Output is correct
11 Correct 48 ms 8028 KB Output is correct
12 Correct 8 ms 8028 KB Output is correct
13 Correct 6 ms 8264 KB Output is correct
14 Correct 5 ms 8028 KB Output is correct
15 Correct 34 ms 8244 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1760 ms 8028 KB Output is correct
18 Correct 664 ms 8028 KB Output is correct
19 Correct 1636 ms 8240 KB Output is correct
20 Correct 3062 ms 8244 KB Output is correct
21 Correct 64 ms 8028 KB Output is correct
22 Correct 54 ms 8028 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Execution timed out 5098 ms 8028 KB Time limit exceeded
25 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 8028 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8024 KB Output is correct
2 Correct 7 ms 8260 KB Output is correct
3 Correct 4 ms 8256 KB Output is correct
4 Correct 35 ms 8028 KB Output is correct
5 Correct 0 ms 408 KB Output is correct
6 Correct 1704 ms 8240 KB Output is correct
7 Correct 652 ms 8028 KB Output is correct
8 Correct 1641 ms 8248 KB Output is correct
9 Correct 3006 ms 8244 KB Output is correct
10 Correct 64 ms 8024 KB Output is correct
11 Correct 48 ms 8028 KB Output is correct
12 Correct 8 ms 8028 KB Output is correct
13 Correct 6 ms 8264 KB Output is correct
14 Correct 5 ms 8028 KB Output is correct
15 Correct 34 ms 8244 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1760 ms 8028 KB Output is correct
18 Correct 664 ms 8028 KB Output is correct
19 Correct 1636 ms 8240 KB Output is correct
20 Correct 3062 ms 8244 KB Output is correct
21 Correct 64 ms 8028 KB Output is correct
22 Correct 54 ms 8028 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Execution timed out 5098 ms 8028 KB Time limit exceeded
25 Halted 0 ms 0 KB -