QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#296334 | #2724. Geese vs. Hawks | Camillus# | 0 | 1ms | 3776kb | C++20 | 2.1kb | 2024-01-02 19:27:14 | 2024-07-04 03:16:33 |
answer
/// @author Camillus <3
#define debug(...) 32
#include "bits/stdc++.h"
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
string s;
cin >> s;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
string t;
cin >> t;
vector<int> b(n);
for (int i = 0; i < n; i++) {
cin >> b[i];
}
int sum = 0;
{
vector<int> W;
vector<int> L;
for (int i = 0; i < n; i++) {
if (s[i] == 'W') {
W.push_back(a[i]);
}
if (t[i] == 'L') {
L.push_back(b[i]);
}
}
debug(W);
debug(L);
int N = (int)W.size();
int M = (int)L.size();
vector<vector<int>> dp(N + 1, vector<int>(M + 1));
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
if (W[i - 1] > L[j - 1]) {
dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + W[i - 1] + L[j - 1]);
}
}
}
sum += dp[N][M];
}
{
vector<int> W;
vector<int> L;
for (int i = 0; i < n; i++) {
if (s[i] == 'L') {
L.push_back(a[i]);
}
if (t[i] == 'W') {
W.push_back(b[i]);
}
}
debug(W);
debug(L);
int N = (int)W.size();
int M = (int)L.size();
vector<vector<int>> dp(N + 1, vector<int>(M + 1));
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= M; j++) {
dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
if (W[i - 1] > L[j - 1]) {
dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + W[i - 1] + L[j - 1]);
}
}
}
sum += dp[N][M];
}
cout << sum << '\n';
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 1ms
memory: 3544kb
input:
1 W 1 L 1
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3776kb
input:
1 L 814908 W 135508
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3600kb
input:
10 LLLLLLLLLL 999999 999999 999999 999999 999999 999999 999999 999999 999999 999999 WWWWWWWWWW 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000 1000000
output:
19999990
result:
ok single line: '19999990'
Test #4:
score: -10
Wrong Answer
time: 0ms
memory: 3548kb
input:
10 LWLLWLWWLW 981331 957383 109887 485485 798286 800461 297097 141919 4785 421857 WLLLLLLWLL 112490 915942 639908 792386 878629 959709 503777 655889 798109 35720
output:
5291048
result:
wrong answer 1st lines differ - expected: '5068671', found: '5291048'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%