QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#393936 | #7990. 广播 | OOBMABTRAMS# | WA | 0ms | 3696kb | C++23 | 738b | 2024-04-19 17:04:18 | 2024-04-19 17:04:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const int N=2102;
int a[N],b[N];
int dp[N][N],mx[N][N];
void solve(){
int m,n;
cin>>n>>m;
for(int i=n;i;i--)cin>>a[i];
for(int j=m;j;j--)cin>>b[j];
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
mx[i][j]=max(mx[i][j-1],mx[i-1][j]);
if(a[i]==b[j]||a[i]==1||b[j]==1)dp[i][j]=max(dp[i][j],mx[i-1][j-1]+1);
mx[i][j]=max(mx[i][j],dp[i][j]);
}
int ans=1e9;
for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
ans=min(ans,i+j-mx[i][j]*2+min(n-i,m-j));
}
cout<<ans<<'\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T=1;
//cin>>T;
while(T--)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
4 2 2 1 3 2 4 2
output:
1
result:
ok single line: '1'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3696kb
input:
1 1 2 3
output:
2
result:
wrong answer 1st lines differ - expected: '1', found: '2'