이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
int places[5001];
vector<int> happy;
vector<int> favourites;
int n, m, a, b;
int memo[2][5001][2][2];
main(){
int k; cin >> k >> n >> m >> a >> b;
happy.push_back(0);
for (int i = 0; i < k; i++){
int g; cin >> g;
happy.push_back(g);
}
for (int i = 0; i < n; i++){
cin >> places[i];
}
for (int i = 0; i < m; i++){
int g; cin >> g;
favourites.push_back(g);
}
int ans = a + m * b;
int idx = 0;
for (int i = 10000; i >= 0; i--){
for (int j = m - 1; j >= 0; j--){
for (int st = false; st <= true; st++){
for (int sf = false; sf <= true; sf++){
int ans = a + (m - j) * b;
if (!st) ans = max(ans, memo[1 - idx][j][true][false] + a + b);
else ans = max(ans, memo[1 - idx][j][true][false] + b);
if (!sf) ans = max(ans, memo[idx][j + 1][false][true] + a + b);
else ans = max(ans, memo[idx][j + 1][false][true] + b);
if (i < n && places[i] == favourites[j]) ans = max(ans, memo[1-idx][j+1][false][false] + happy[places[i]]);
memo[idx][j][st][sf] = ans;
}
}
}
if (i < n)ans = max(ans, memo[idx][0][false][false]);
idx = 1 - idx;
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
VisitingSingapore.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |