fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_SIZE = 20;
  5.  
  6. int main() {
  7. int n, m , x, y, mt[MAX_SIZE + 1][MAX_SIZE + 1];
  8. cin >> n >> m >> x >> y;
  9. for (int i = 1; i <= n; ++i) {
  10. for (int j = 1; j <= m; ++j) {
  11. cin >> mt[i][j];
  12. }
  13. }
  14. int counterSteps = 0, xSteps = x, ySteps = y;
  15. int pointY = 0, pointX = 0;
  16. int a = n, b = 0;
  17. for (int j = 1; j <= n; ++j) {
  18. a = 1 + ySteps;
  19. b = 1 + xSteps;
  20. if (pointY + a <= n && ySteps > -1) {
  21. pointY += a;
  22. ++counterSteps;
  23. }
  24. if (pointX + b <= m && xSteps > -1 ) {
  25. pointX += b;
  26. ++counterSteps;
  27. }
  28. --ySteps;
  29. --xSteps;
  30. }
  31. cout << counterSteps;
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5324KB
stdin
7 2 
1 1 
1 2 
1 2 
1 2 
1 2 
1 2 
1 2 
1 2 
stdout
3