Advertisement
STANAANDREY

tnia

Mar 6th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <fstream>
  2. using namespace std;
  3. ifstream f("tnia.in");
  4. ofstream g("tnia.out");
  5. //unsigned long long h[1000001];
  6. short mat[1000][100000];
  7. int main (){
  8.  
  9. unsigned long long n,m,i,line,col=1,q,h,S,A,B,C,D;
  10. f>>n>>m;
  11. for (i=1;i<=n;i++) //generez matricea
  12. {
  13. f>>h;
  14. for (line=1;line<=h;line++)
  15. mat[line][col]=1;
  16.    col++;
  17. }
  18. f>>q;
  19. for (i=1;i<=q;i++)
  20. { S=0;
  21. f>>A>>B>>C>>D;
  22. for (col=A;col<=C;col++) {
  23.     for (line=B;line<=D;line++)
  24.     S+=mat[line][col];
  25. }
  26. g<<S<<"\n";
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement