Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream f("tnia.in");
- ofstream g("tnia.out");
- //unsigned long long h[1000001];
- short mat[1000][100000];
- int main (){
- unsigned long long n,m,i,line,col=1,q,h,S,A,B,C,D;
- f>>n>>m;
- for (i=1;i<=n;i++) //generez matricea
- {
- f>>h;
- for (line=1;line<=h;line++)
- mat[line][col]=1;
- col++;
- }
- f>>q;
- for (i=1;i<=q;i++)
- { S=0;
- f>>A>>B>>C>>D;
- for (col=A;col<=C;col++) {
- for (line=B;line<=D;line++)
- S+=mat[line][col];
- }
- g<<S<<"\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement