T3000

Untitled

Mar 24th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = long long;
  5.  
  6. int main()
  7. {
  8.     ll n;
  9.     cin >> n;
  10.     vector<vector<ll>> z1(n, vector<ll>(n, 0));
  11.     for (int i = 0; i < n; i++)
  12.     {
  13.         for (int j = 0; j < n; j++)
  14.         {
  15.             cin >> z1.at(i).at(j);
  16.         }
  17.     }
  18.     ll pr, sN = 0, sS = 0, sE = 0, sW = 0;
  19.     if (n % 2 == 0)
  20.     {
  21.         pr = n / 2 - 1;
  22.     }
  23.     else
  24.     {
  25.         pr = n / 2;
  26.     }
  27.  
  28.     for (int i = 0, h = 1; i < pr; i++, h++)
  29.     {
  30.         int w;
  31.         sN += accumulate(z1.at(i).begin() + h, z1.at(i).begin() + n - h, w);
  32.     }
  33.     cout << sN << endl;
  34.  
  35.     return 0;
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment