QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#296336#2724. Geese vs. HawksCamillus#25 ✓6ms10952kbC++201.1kb2024-01-02 19:32:182024-07-04 03:16:34

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 03:16:34]
  • 评测
  • 测评结果:25
  • 用时:6ms
  • 内存:10952kb
  • [2024-01-02 19:32:18]
  • 提交

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];
    }

    vector<vector<int>> dp(n + 1, vector<int>(n + 1));

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s[i - 1] == 'W' && t[j - 1] == 'L' && a[i - 1] > b[j - 1]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + a[i - 1] + b[j - 1]);
            }
            if (s[i - 1] == 'L' && t[j - 1] == 'W' && a[i - 1] < b[j - 1]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + a[i - 1] + b[j - 1]);
            }
        }
    }

    cout << dp[n][n] << '\n';
    return 0;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 3616kb

input:

1
W
1
L
1

output:

0

result:

ok single line: '0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

1
L
814908
W
135508

output:

0

result:

ok single line: '0'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3824kb

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: 0
Accepted
time: 0ms
memory: 3764kb

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:

5068671

result:

ok single line: '5068671'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

7
LWLLLWL
171226 301982 706206 797460 31841 316622 276986
LLWWWLW
872626 46182 149148 97154 994293 823644 822089

output:

3668212

result:

ok single line: '3668212'

Subtask #2:

score: 15
Accepted

Dependency #1:

100%
Accepted

Test #6:

score: 15
Accepted
time: 0ms
memory: 3484kb

input:

1
W
1
L
1

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

1
L
814908
W
135508

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 4ms
memory: 10952kb

input:

1000
LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL...

output:

1999999000

result:

ok single line: '1999999000'

Test #9:

score: 0
Accepted
time: 3ms
memory: 10224kb

input:

953
LWLLWLWWLWWLLLLLLWLLLLWWLLWWWWWLLLLLLLLWWLWLLLWLLLWWWLWWWLLWWWLWWWLLLLWWLLWWLWWWWLWLWWWWWWWLLLLLLWLLWLLWLWWWLLLWLLLWWLLWLLLLWLWLLLWWLWWWLLLWWLWWWLWWLWLWLLLWLWWLLLLLLLLWLLWLLWWLLWWWWLLLWLLWWLWWWWLWWWLLWWLLLWWLWWWLLLLLLWLWLWLLLWLLWLLLWWLWLWWLLWWLLLWLLWWWLWWLLWLLWWLWWWWWLLWLLLWWLLLLWWWLWWWWLWWWWWLW...

output:

599012643

result:

ok single line: '599012643'

Test #10:

score: 0
Accepted
time: 0ms
memory: 9708kb

input:

903
LWWLWWLLLLLLWWWWWLWLLLLLLLLLWLWWWLLWWWWLLWLWLLWWLWLWWWLWWLWWLWLWLWWLWWWLWLWLWLWWLWLLWWLLLLLLWWWLWWWWWWLLWLWLWLWWLLLWWLWLLLLLWLWWLWWLLWWWLWWWLLLLLLLWWLWLWLLLLWLLLWLLLLWLLWLLWWWWLLLLWWWLWLLWWWLWLWLWLLWWLLWWWLLWWLLLWWWWWWWWWWWWWLWLWLLWLLWWLLLLWWWLWLLLLLLLWWLWLWWLWLWWLWLLWLLLLWWLLLLWWWLWWLLLLWLLLLWW...

output:

585414481

result:

ok single line: '585414481'

Test #11:

score: 0
Accepted
time: 3ms
memory: 5748kb

input:

585
WWLWLLLWWLWLWWLLLLWLLLLLWWLLWLWWLWLLLWWLLWWWLLLWLLLWWWWLWLLLLLLLLLWLWWWWWLLWLWLLWLWWWLWWWWWWWWWWLWLLWLLWLWLWWWLWWWLWWWWLWLWLWLLLWWLLWLWLLWWLLWWLLLWWWLWWLWLWWWLWWLWLLLLLWLWLLLWLWLLLWWLLWWLLWLLLLWLWLWLLLLLWLWWLLLWLWWLWWLLWLWWWLLLWLLLWWLLLLLLLLWLLLWWWWWLLWWWWLWLLLWLWLLLLWLWWWWLLLLWLLWWWWWWLLLLLLWLW...

output:

361523461

result:

ok single line: '361523461'

Test #12:

score: 0
Accepted
time: 0ms
memory: 7344kb

input:

718
LWWLWLWWLLWLWWLLLLWLWWWWWWLWLWLLLLWWLLWWLLLWWWWLWWLLWWWLWLWLWWLWWLLLWWLLWLWWLWLWLLWLLLWWWWWLWLWWWWWWWLWWLWLLWWLLLLLLWLWLLWLWWLWLLLLLLLWWLWLWWWWWWLLLWLWLLLLWWWWLLWWWLLWLLWLLLLWWLWLLLLWLLLLLWLLWWWLLWLWLWLLLWLWLLLLLWWLWLLWLLLWWLWWLWWLLWLLLLLWWWWLLWLLLWWWLWWLLWWWWLWLLLWWWWWLLWLWLLLLLWLLWWWLWWLWWLLWL...

output:

455346204

result:

ok single line: '455346204'

Test #13:

score: 0
Accepted
time: 0ms
memory: 9836kb

input:

916
WLLWWLLLLWWWWLWLWLLLWLLWWWWWWWWLWLWWWWWWWLWWWLLWLLWLWWWWWWLWWWLWWLWWWLLLWLWLWLWLLLLWLLWLLLLLLWWLWLWLWLLWLLWLLWWLLWWWWLWLLWLLLWWWWWLWLWLWLWLWLLWLWWLWLWLWLLWWWLLWWLWLLLLLLLLLLWWLWWLWWWWWWWLWLWLWWLWLLLWWLLWLLLLWWLLWLLLLWLWWLLLLWLWWLWWWLWWWLWWLLLWWWLWLWLWWLLWWWLLLWWWLWLWWLWWWLWLWLLWWLLLWWLLLWLWWLWWW...

output:

579628943

result:

ok single line: '579628943'

Test #14:

score: 0
Accepted
time: 6ms
memory: 9592kb

input:

897
LLWLWWWWWWLWLWLLLWLLWWLWWWWWLLWWWLWWWWLLWLLLWLLWLWLLWWLWWLWLWWWWWWWLWLWLWWLLWLLLWLLLLWWLLLWLLWLLWWLLLLWWLWWWLWWLLWWWWWLWWLWLWLWLLWLLLLLWWWWLLWWWLLWWLLLWLWWLWWWWLWWWLWWLLWLWWLWLWLWLWLWLLWLLWLWWLLLWLWLLLWWWLLWWWWLLLLLWLWWLWLWLLWWWWLLWWWWLLWLWLWWWWLWLLWLWLLWWWWWWLWWWLWWWWWLLLWLLLWWLLLLLWLWWWWLLLWLW...

output:

556394273

result:

ok single line: '556394273'

Test #15:

score: 0
Accepted
time: 3ms
memory: 10196kb

input:

943
LWWLWWLLLLLLWLLWWLWWLLLLWWWWWWWLWWWWLWWWWLWLWWWWLWLWLWWWWWWLLLLWWWWLLLWLLWLWWLLWWLLLWLWWLLLWLLWLLWLWLWWLLLLWWWWWWLLWLWWWWWWWLLLWLWWWWWWWWWWWLLWLWWWLLWLWWWWLWLWWLWWWWWLWWLLLWLLLWLLLLLLLLWWLLWWWWWWWLWLWLWWLLLWWLLLWWWLLLLWLWLLWLWWWWWWLWWWLLWWWWLWLWLLLLWWWWLLWWLWLWWWLLWLWWWLLWLLLWLLLLLWWWLLLWWLWLLLW...

output:

593264983

result:

ok single line: '593264983'

Extra Test:

score: 0
Extra Test Passed