From 0e39cd7712206e111b82b4d40bcf915dc027b12b Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 23 Oct 2022 15:02:02 +0800 Subject: [PATCH] D - The Winter Hike https://codeforces.com/contest/1621/submission/177527841 --- Codeforces/1621/D/D.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Codeforces/1621/D/D.cpp diff --git a/Codeforces/1621/D/D.cpp b/Codeforces/1621/D/D.cpp new file mode 100644 index 00000000..75d88f1e --- /dev/null +++ b/Codeforces/1621/D/D.cpp @@ -0,0 +1,38 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 255; + +int t, n, a[N][N]; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + cin >> t; + + while (t--) { + cin >> n; + + for (int i = 1; i <= n << 1; i++) { + for (int j = 1; j <= n << 1; j++) { + cin >> a[i][j]; + } + } + + long long ans = 0; + for (int i = n + 1; i <= n + n; i++) { + for (int j = n + 1; j <= n + n; j++) { + ans += a[i][j]; + } + } + + cout << ans + std::min({a[1][n + 1], a[1][n + n], a[n][n + 1], a[n][n + n], a[n + 1][n], a[n + 1][1], a[n + n][1], a[n + n][n]}) << endl; + } + + return 0; +}