Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
1.1 kB
6
Indexable
Never
#include <iostream>
#include <vector>
using namespace std;



int N, M;
vector<int> row;
vector<int> col;

int H, W;

int main(void){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin >> N >> M;

    int tmp;
    for(int i = 0;i<N;i++){
        cin >> tmp;
        row.push_back(tmp);
    }

    
    for(int j = 0;j<M;j++){
        cin >> tmp;
        col.push_back(tmp);
    }

    int col_cnt = 0;

    cin >> H >> W;

    int r_i = 0;
    int r_j = 0;
    long long r_sum = 0;
    int r_cnt = 0;
    while(r_i<=r_j && r_j<N){
        if(r_sum >= H){
            r_sum -= row[r_i++];
        }else{
            r_sum += row[r_j++];
        }
        if(r_sum == H) r_cnt++;
    }

    // cout << r_cnt << '\n';

    int c_i = 0;
    int c_j = 0;
    long long c_sum = 0;
    int c_cnt = 0;
    while(c_i<=c_j && c_j!=M){
        if(c_sum >= W){
            c_sum -= col[c_i++];
        }else{
            c_sum += col[c_j++];
        }
        if(c_sum == W) c_cnt++;
    }
    // cout << c_cnt << '\n';

    cout << r_cnt * c_cnt << '\n';
}