QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#177213 | #2724. Geese vs. Hawks | lmeowdn | 25 ✓ | 6ms | 11696kb | C++14 | 1.7kb | 2023-09-12 17:54:50 | 2023-09-12 17:54:51 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
ll read() {
ll x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
return x*w;
}
const int N=1005;
int n,a[N],m,b[N],f[N][N];
char s[N],t[N];
signed main() {
n=read();
scanf("%s",s+1);
rep(i,1,n) a[i]=read();
scanf("%s",t+1);
rep(i,1,n) b[i]=read();
rep(i,1,n) rep(j,1,n) {
f[i][j]=max(f[i-1][j],f[i][j-1]);
if(s[i]=='W'&&t[j]=='L'&&a[i]>b[j])
chmax(f[i][j],f[i-1][j-1]+a[i]+b[j]);
if(s[i]=='L'&&t[j]=='W'&&a[i]<b[j])
chmax(f[i][j],f[i-1][j-1]+a[i]+b[j]);
}
printf("%lld\n",f[n][n]);
return 0;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 0ms
memory: 3836kb
input:
1 W 1 L 1
output:
0
result:
ok single line: '0'
Test #2:
score: 0
Accepted
time: 0ms
memory: 4096kb
input:
1 L 814908 W 135508
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3888kb
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: 3872kb
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: 3824kb
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: 3904kb
input:
1 W 1 L 1
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
1 L 814908 W 135508
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 4ms
memory: 11696kb
input:
1000 LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL...
output:
1999999000
result:
ok single line: '1999999000'
Test #9:
score: 0
Accepted
time: 3ms
memory: 11304kb
input:
953 LWLLWLWWLWWLLLLLLWLLLLWWLLWWWWWLLLLLLLLWWLWLLLWLLLWWWLWWWLLWWWLWWWLLLLWWLLWWLWWWWLWLWWWWWWWLLLLLLWLLWLLWLWWWLLLWLLLWWLLWLLLLWLWLLLWWLWWWLLLWWLWWWLWWLWLWLLLWLWWLLLLLLLLWLLWLLWWLLWWWWLLLWLLWWLWWWWLWWWLLWWLLLWWLWWWLLLLLLWLWLWLLLWLLWLLLWWLWLWWLLWWLLLWLLWWWLWWLLWLLWWLWWWWWLLWLLLWWLLLLWWWLWWWWLWWWWWLW...
output:
599012643
result:
ok single line: '599012643'
Test #10:
score: 0
Accepted
time: 6ms
memory: 11012kb
input:
903 LWWLWWLLLLLLWWWWWLWLLLLLLLLLWLWWWLLWWWWLLWLWLLWWLWLWWWLWWLWWLWLWLWWLWWWLWLWLWLWWLWLLWWLLLLLLWWWLWWWWWWLLWLWLWLWWLLLWWLWLLLLLWLWWLWWLLWWWLWWWLLLLLLLWWLWLWLLLLWLLLWLLLLWLLWLLWWWWLLLLWWWLWLLWWWLWLWLWLLWWLLWWWLLWWLLLWWWWWWWWWWWWWLWLWLLWLLWWLLLLWWWLWLLLLLLLWWLWLWWLWLWWLWLLWLLLLWWLLLLWWWLWWLLLLWLLLLWW...
output:
585414481
result:
ok single line: '585414481'
Test #11:
score: 0
Accepted
time: 3ms
memory: 9632kb
input:
585 WWLWLLLWWLWLWWLLLLWLLLLLWWLLWLWWLWLLLWWLLWWWLLLWLLLWWWWLWLLLLLLLLLWLWWWWWLLWLWLLWLWWWLWWWWWWWWWWLWLLWLLWLWLWWWLWWWLWWWWLWLWLWLLLWWLLWLWLLWWLLWWLLLWWWLWWLWLWWWLWWLWLLLLLWLWLLLWLWLLLWWLLWWLLWLLLLWLWLWLLLLLWLWWLLLWLWWLWWLLWLWWWLLLWLLLWWLLLLLLLLWLLLWWWWWLLWWWWLWLLLWLWLLLLWLWWWWLLLLWLLWWWWWWLLLLLLWLW...
output:
361523461
result:
ok single line: '361523461'
Test #12:
score: 0
Accepted
time: 2ms
memory: 9856kb
input:
718 LWWLWLWWLLWLWWLLLLWLWWWWWWLWLWLLLLWWLLWWLLLWWWWLWWLLWWWLWLWLWWLWWLLLWWLLWLWWLWLWLLWLLLWWWWWLWLWWWWWWWLWWLWLLWWLLLLLLWLWLLWLWWLWLLLLLLLWWLWLWWWWWWLLLWLWLLLLWWWWLLWWWLLWLLWLLLLWWLWLLLLWLLLLLWLLWWWLLWLWLWLLLWLWLLLLLWWLWLLWLLLWWLWWLWWLLWLLLLLWWWWLLWLLLWWWLWWLLWWWWLWLLLWWWWWLLWLWLLLLLWLLWWWLWWLWWLLWL...
output:
455346204
result:
ok single line: '455346204'
Test #13:
score: 0
Accepted
time: 6ms
memory: 11036kb
input:
916 WLLWWLLLLWWWWLWLWLLLWLLWWWWWWWWLWLWWWWWWWLWWWLLWLLWLWWWWWWLWWWLWWLWWWLLLWLWLWLWLLLLWLLWLLLLLLWWLWLWLWLLWLLWLLWWLLWWWWLWLLWLLLWWWWWLWLWLWLWLWLLWLWWLWLWLWLLWWWLLWWLWLLLLLLLLLLWWLWWLWWWWWWWLWLWLWWLWLLLWWLLWLLLLWWLLWLLLLWLWWLLLLWLWWLWWWLWWWLWWLLLWWWLWLWLWWLLWWWLLLWWWLWLWWLWWWLWLWLLWWLLLWWLLLWLWWLWWW...
output:
579628943
result:
ok single line: '579628943'
Test #14:
score: 0
Accepted
time: 5ms
memory: 11160kb
input:
897 LLWLWWWWWWLWLWLLLWLLWWLWWWWWLLWWWLWWWWLLWLLLWLLWLWLLWWLWWLWLWWWWWWWLWLWLWWLLWLLLWLLLLWWLLLWLLWLLWWLLLLWWLWWWLWWLLWWWWWLWWLWLWLWLLWLLLLLWWWWLLWWWLLWWLLLWLWWLWWWWLWWWLWWLLWLWWLWLWLWLWLWLLWLLWLWWLLLWLWLLLWWWLLWWWWLLLLLWLWWLWLWLLWWWWLLWWWWLLWLWLWWWWLWLLWLWLLWWWWWWLWWWLWWWWWLLLWLLLWWLLLLLWLWWWWLLLWLW...
output:
556394273
result:
ok single line: '556394273'
Test #15:
score: 0
Accepted
time: 6ms
memory: 11512kb
input:
943 LWWLWWLLLLLLWLLWWLWWLLLLWWWWWWWLWWWWLWWWWLWLWWWWLWLWLWWWWWWLLLLWWWWLLLWLLWLWWLLWWLLLWLWWLLLWLLWLLWLWLWWLLLLWWWWWWLLWLWWWWWWWLLLWLWWWWWWWWWWWLLWLWWWLLWLWWWWLWLWWLWWWWWLWWLLLWLLLWLLLLLLLLWWLLWWWWWWWLWLWLWWLLLWWLLLWWWLLLLWLWLLWLWWWWWWLWWWLLWWWWLWLWLLLLWWWWLLWWLWLWWWLLWLWWWLLWLLLWLLLLLWWWLLLWWLWLLLW...
output:
593264983
result:
ok single line: '593264983'
Extra Test:
score: 0
Extra Test Passed