Submission #949630

# Submission time Handle Problem Language Result Execution time Memory
949630 2024-03-19T13:12:31 Z ifateen Uplifting Excursion (BOI22_vault) C++17
0 / 100
5000 ms 8420 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int OFFSET, OFFSET_SUM;
signed main() {
    int n, l;
    cin >> n >> l;
    vector<int> v(2 * n + 1);
    for (auto& i : v) cin >> i;
    int dp[2][250'005];
    OFFSET = n, OFFSET_SUM = n * 50 * 50;
    for (int i = 0; i <= 2 * OFFSET_SUM; ++i) dp[0][i] = dp[1][i] = -1e9;
    dp[1][OFFSET_SUM] = 0;
    for (int i = 0; i <= 2 * n; ++i) {
        int actual_value = i - OFFSET;
        for (int j = 0; j <= OFFSET_SUM * 2; ++j) {
            dp[i & 1][j] = max(dp[i & 1][j], dp[i & 1 ^ 1][j]);
            for (int k = 1; k <= v[i]; ++k) {
                int prv_sum = j - k * actual_value;
                if (prv_sum < 0 || prv_sum > OFFSET_SUM * 2) continue;
                dp[i & 1][j] = max(dp[i & 1][j], dp[i & 1 ^ 1][prv_sum] + k);
            }
        }
    }
    int ans = dp[0][OFFSET_SUM + l];
    if (ans <= 0) cout << "impossible";
    else cout << ans;
}

Compilation message

vault.cpp: In function 'int main()':
vault.cpp:17:51: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   17 |             dp[i & 1][j] = max(dp[i & 1][j], dp[i & 1 ^ 1][j]);
      |                                                 ~~^~~
vault.cpp:21:55: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   21 |                 dp[i & 1][j] = max(dp[i & 1][j], dp[i & 1 ^ 1][prv_sum] + k);
      |                                                     ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4188 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4188 KB Output is correct
4 Correct 7 ms 4188 KB Output is correct
5 Runtime error 1220 ms 8420 KB Execution killed with signal 7
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4188 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4188 KB Output is correct
4 Correct 7 ms 4188 KB Output is correct
5 Runtime error 1220 ms 8420 KB Execution killed with signal 7
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Execution timed out 5062 ms 4188 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Execution timed out 5062 ms 4188 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Execution timed out 5062 ms 4188 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4188 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4188 KB Output is correct
4 Correct 7 ms 4188 KB Output is correct
5 Runtime error 1220 ms 8420 KB Execution killed with signal 7
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Execution timed out 5062 ms 4188 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4188 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4188 KB Output is correct
4 Correct 7 ms 4188 KB Output is correct
5 Runtime error 1220 ms 8420 KB Execution killed with signal 7
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 4188 KB Output is correct
2 Execution timed out 5062 ms 4188 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4188 KB Output is correct
2 Correct 2 ms 4188 KB Output is correct
3 Correct 2 ms 4188 KB Output is correct
4 Correct 7 ms 4188 KB Output is correct
5 Runtime error 1220 ms 8420 KB Execution killed with signal 7
6 Halted 0 ms 0 KB -