fork download
  1. //Bai 17
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. #define el "\n"
  6. #define ll long long
  7. #define ull unsigned long long
  8. #define se second
  9. #define fi first
  10. #define be begin()
  11. #define en end()
  12. #define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
  13. int n,m;
  14. void Run()
  15. {
  16. cin >> n >> m;
  17. ll ans = 0;
  18. for(int i = 0; i < n; i++)
  19. {
  20. for(int j = 0; j < m; j++)
  21. {
  22. int x; cin >> x;
  23. if(i == 0 || i == n-1 || j == 0 || j == n-1) ans += 1ll*x;
  24. }
  25. }
  26. cout << ans;
  27. }
  28. int main()
  29. {
  30. Faster;
  31. Run();
  32. return 0;
  33. }
  34.  
  35.  
Success #stdin #stdout 0s 5264KB
stdin
Standard input is empty
stdout
Standard output is empty