QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226028 | #6422. Evil Coordinate | kokomiisbest | WA | 3ms | 96656kb | C++14 | 846b | 2023-10-25 14:49:46 | 2023-10-25 14:49:47 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10,K=100+19;
int f[N][K][2];
int w[N];
int n,k;
int main(){
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>w[i];
memset(f,-0x3f,sizeof f);
f[0][0][0]=0;
for(int i=1;i<=n;i++){
for(int j=0;j<=k;j++){
// f[i][j][0]=f[i-1][j][0];
// //\xc2\xf4\xb3\xf6
// if(j) f[i][j][0]=max(f[i][j][0],f[i-1][j-1][1]+w[i]);
// //\xc2\xf2\xc8\xeb
// f[i][j][1]=max(f[i-1][j][1],f[i-1][j][0]-w[i]);
//\xbf\xc9\xd2\xd4\xd3ù\xf6\xb6\xaf\xca\xfd\xd7\xe9\xd3Ż\xaf
f[i&1][j][0]=f[(i-1)&1][j][0];
if(j) f[i&1][j][0]=max(f[i&1][j][0],f[(i-1)&1][j-1][1]+w[i]);
f[i&1][j][1]=max(f[(i-1)&1][j][1],f[(i-1)&1][j][0]-w[i]);
}
}
int res=0;
for(int i=0;i<=k;i++) res=max(res,f[n&1][i][0]);
cout<<res;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 96656kb
input:
5 1 1 RURULLD 0 5 UUU 0 3 UUU 0 2 UUU 0 0 UUU
output:
0
result:
wrong answer Line "0" doesn't correspond to pattern "[UDLR]{1,100000}|Impossible"