Submission
Status:
[P][P][T][TS][TS][TS][TS][TS][TS][TS]
Subtask/Task Score:
{10/10}{10/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}{0/10}
Score: 20
User: Nuttykub
Problemset: ตัดกระดาษ
Language: cpp
Time: 1.096 second
Submitted On: 2026-10-18 17:33:50
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll l,w,n,m,q;
cin>>l>>w>>n>>m>>q;
queue<int> getx;
queue<int> gety;
for(int i =0;i<n;i++) {
int x;
cin>>x;
getx.push(x);
}
for(int i =0;i<m;i++) {
int x;
cin>>x;
gety.push(x);
}
getx.push(l);
gety.push(w);
queue<int> newgetx = getx;
queue<int> newgety = gety;
while(q--){
int ct=0;
int area;
cin>>area;
int tmpx = 0,tmpy=0;
int value_x,value_y,a;
getx = newgetx;
for(int i =0;i <n+1;i++){
value_x = getx.front()-tmpx;
gety = newgety;
tmpy = 0;
for(int j=0;j<m+1;j++) {
value_y = gety.front()-tmpy;
a = value_y*value_x;
if(a == area) ct++;
tmpy = gety.front();
gety.pop();
}
tmpx = getx.front();
getx.pop();
}
cout << ct << endl;
}
}