Submission #692484

# Submission time Handle Problem Language Result Execution time Memory
692484 2023-02-01T14:07:09 Z saayan007 Visiting Singapore (NOI20_visitingsingapore) C++17
4 / 100
212 ms 262144 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vpi = vector<pi>;
using vpl = vector<pl>;

#define fur(i, a, b) for(ll i = a; i <= (ll) b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll) b; --i)
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define nl "\n"

const ll inf = 1e10L;

ll cost(ll x, ll y) {
    if(y & 1) {
        return  1;
    }
    return 0;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll k, n, m, a, b;
    cin >> k >> n >> m >> a >> b;
    ll v[k + 1], s[n + 1], t[m + 1];

    fur(i, 1, k) {
        cin >> v[i];
    }
    fur(i, 1, n) {
        cin >> s[i];
    }
    fur(i, 1, m) {
        cin >> t[i];
    }

    ll dp[n + 1][m + 1][4];
    fur(i, 0, n) {
        fur(j, 0, m) {
            fur(x, 0, 3)
                dp[i][j][x] = -inf;
        }
    }

    ll res = -inf;
    dp[0][0][3] = 0;
    fur(j, 1, m) {
        dp[0][j][2] = a;
    }
    res = max(res, dp[0][m][1]);

    fur(i, 1, n) {
        fur(j, 1, m) {
            fur(y, 0, 3) {
                dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][y] + a * (y % 4 > 1));
                dp[i][j][2] = max(dp[i][j][2], dp[i][j - 1][y] + a * (y % 4 < 2));

                if(s[i] == t[j]) {
                    dp[i][j][3] = max(dp[i][j][3], v[s[i]] + a * ((i > 1) + (j > 1)));
                    dp[i][j][3] = max(dp[i][j][3], dp[i - 1][j - 1][y] + v[s[i]]);
                }
            }
        }
        fur(x, 0, 3)
            res = max(res, dp[i][m][x]);
    }
    cout << res << nl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 27 ms 26796 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 10 ms 7636 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 3 ms 2388 KB Output is correct
9 Correct 17 ms 15164 KB Output is correct
10 Correct 33 ms 31660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 75884 KB Output is correct
2 Correct 26 ms 30548 KB Output is correct
3 Correct 212 ms 257196 KB Output is correct
4 Runtime error 97 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 75884 KB Output is correct
2 Correct 26 ms 30548 KB Output is correct
3 Correct 212 ms 257196 KB Output is correct
4 Runtime error 97 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 75884 KB Output is correct
2 Correct 26 ms 30548 KB Output is correct
3 Correct 212 ms 257196 KB Output is correct
4 Runtime error 97 ms 262144 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 27 ms 26796 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 10 ms 7636 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
8 Correct 3 ms 2388 KB Output is correct
9 Correct 17 ms 15164 KB Output is correct
10 Correct 33 ms 31660 KB Output is correct
11 Incorrect 1 ms 596 KB Output isn't correct
12 Halted 0 ms 0 KB -