Submission

Status:
[P][P][P][PP][PT][xS][xS][xS][xS][xS]

Score: 40

User: Ecir

Problemset: ตัดกระดาษ

Language: cpp

Time: 1.074 second

Submitted On: 2025-03-25 15:33:48

#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define twod array<ll,2>
const int modd=2009;
map<int,int> mpy;
int dp[100009];
int main(){
  ios::sync_with_stdio(0);cin.tie(0);
  int sy,sx,ny,nx,nn;cin >> sy >> sx >> ny >> nx >> nn;
  int cmp=0;
  for(int i=1;i<=ny;i++){
    int z;cin >> z;
    mpy[z-cmp]++;
    cmp=z;
  }
  mpy[sy-cmp]++;
  cmp=0;
  for(int i=1;i<=nx;i++){
    int z;cin >> z;
    for(auto e:mpy){
      if((z-cmp)*e.first>100000) break;
      dp[(z-cmp)*e.first]+=e.second;
    }
    cmp=z;
  }
  for(auto e:mpy){
    if((sx-cmp)*e.first>100000) break;
    dp[(sx-cmp)*e.first]+=e.second;
  }
  while(nn--){
    int z;cin >> z;
    cout << dp[z] << "\n";
  }
  
  return 0;
}