fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main() {
  8. // your code goes here
  9. int n ;
  10. cin>>n;
  11. int x ; cin>>x;
  12. vector<vector<int>>mat(n,vector<int>(n,0));
  13. for(int i = 0 ; i<n;i++){
  14. for(int j = 0; j<n;j++){
  15. cin>>mat[i][j];
  16. }
  17. }
  18.  
  19. int count = 0 ;
  20. int j = n-1,i = 0;
  21. while(i<=n-1 && j>=0){
  22. if(mat[i][j]>x){
  23. j--;
  24. }
  25. else{
  26. count+=j+1;
  27. i++;
  28.  
  29. }
  30.  
  31. }
  32. cout<<count;
  33. return 0;
  34. }
Success #stdin #stdout 0s 5312KB
stdin
4
8
1 2 7 11
5 7 8 12
6 8 8 15
7 8 9 10
stdout
11