比赛 |
2024暑期C班集训2 |
评测结果 |
AAAEEEEEEE |
题目名称 |
雨滴之歌 |
最终得分 |
30 |
用户昵称 |
┭┮﹏┭┮ |
运行时间 |
1.497 s |
代码语言 |
C++ |
内存使用 |
7.32 MiB |
提交时间 |
2024-07-02 10:08:27 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5+10;
const ll mod = 1e9+7;
ll read(){
ll x = 0,f = 1;char c = getchar();
for(;c < '0' || c > '9';c = getchar())if(c == '-')f = -1;
for(;c >= '0' && c <= '9';c = getchar())x = (x<<1) + (x<<3) + c-'0';
return x * f;
}
int n,m,t;
ll a[N],b[N],ans;
int v[310][310];
bool check(int x,int y){
if(a[x] + b[y] < 0)return v[x][y] = 0;
if(v[x][y] != -1)return v[x][y];
if(x == t && y == m)return 1;
bool f = 0;
if(x < t)f |= check(x+1,y);
if(y < m)f |= check(x,y+1);
return v[x][y] = f;
}
int main(){
freopen("expansion.in","r",stdin);
freopen("expansion.out","w",stdout);
n = read(),m = read();
for(int i = 1;i <= n;i++)a[i] = read();
for(int i = 1;i <= m;i++)b[i] = read();
for(int j = n;j >= 1;j--){
memset(v,-1,sizeof v);t = j;
for(int i = j;i >= 1;i--)
if(check(i,1))ans++;
}
printf("%lld\n",ans);
return cerr<<clock()<<"ms"<<endl,0;
}