Submission
Status:
[P][P][P][PP][PP][PP][PP][PP][PP][PP]
Score: 100
User: Ecir
Problemset: ตัดกระดาษ
Language: cpp
Time: 0.100 second
Submitted On: 2025-03-25 15:48:10
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define twod array<ll,2>
const int modd=2009;
// map<ll,int> mpy;
vector<int> vct;
int mpy[100009];
ll 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;
if(z-cmp<=100000) {
mpy[z-cmp]++;
vct.push_back(z-cmp);
}
cmp=z;
}
if(sy-cmp<=100000) {
mpy[sy-cmp]++;
vct.push_back(sy-cmp);
}
cmp=0;
sort(vct.begin(),vct.end());
vct.resize(unique(vct.begin(),vct.end())-vct.begin());
for(int i=1;i<=nx;i++){
int z;cin >> z;
for(auto e:vct){
if(1ll*(z-cmp)*e>100000) break;
dp[(z-cmp)*e]+=mpy[e];
}
cmp=z;
}
for(auto e:vct){
if(1ll*(sx-cmp)*e>100000) break;
dp[(sx-cmp)*e]+=mpy[e];
}
while(nn--){
int z;cin >> z;
cout << dp[z] << "\n";
}
return 0;
}