Josif_tepe

Untitled

Mar 21st, 2026
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n, m;
  8.     cin >> n >> m;
  9.    
  10.     int mat[n][m];
  11.     for(int i = 0; i < n; i++) {
  12.         for(int j = 0; j < m; j++) {
  13.             cin >> mat[i][j];
  14.         }
  15.     }
  16.    
  17.     bool ok = true;
  18.    
  19.     for(int j = 0; j < m - 1; j++) {
  20.         int najgolem = mat[0][j];
  21.         int najgolem2 = mat[0][j + 1];
  22.        
  23.         for(int i = 0; i < n; i++) {
  24.             if(mat[i][j] > najgolem) {
  25.                 najgolem = mat[i][j];
  26.             }
  27.            
  28.             if(mat[i][j + 1] > najgolem2) {
  29.                 najgolem2 = mat[i][j + 1];
  30.             }
  31.            
  32.         }
  33.         if(najgolem >= najgolem2) {
  34.             ok = false;
  35.             break;
  36.         }
  37.     }
  38.    
  39.     if(ok) {
  40.         cout << "DA" << endl;
  41.     }
  42.     else {
  43.         cout << "NE" << endl;
  44.     }
  45.     return 0;
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment