Submission #692468

#TimeUsernameProblemLanguageResultExecution timeMemory
692468saayan007Visiting Singapore (NOI20_visitingsingapore)C++17
16 / 100
221 ms196080 KiB
#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" 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] = {}; fur(i, 1, n) { fur(j, 1, m) { dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]); if(s[i] == t[j]) { dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + v[s[i]]); } } } cout << dp[n][m] << nl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...