2 solutions
-
0
Guest MOD
-
0
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int a[n][m]; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { cin >> a[i][j]; } } int mx = 0; for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { int now = 0; int ci = i, cj = j; while(ci >= 0 && ci < n && cj >= 0 && cj < m) { now+=a[ci][cj]; ci--; cj--; } ci = i, cj = j; while(ci >= 0 && ci < n && cj >= 0 && cj < m) { now+=a[ci][cj]; ci++; cj--; } ci = i, cj = j; while(ci >= 0 && ci < n && cj >= 0 && cj < m) { now+=a[ci][cj]; ci--; cj++; } ci = i, cj = j; while(ci >= 0 && ci < n && cj >= 0 && cj < m) { now+=a[ci][cj]; ci++; cj++; } now-=a[i][j]*3; mx = max(mx, now); } } cout << mx << endl; }
- 1
Information
- ID
- 1446
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- (None)
- # Submissions
- 92
- Accepted
- 35
- Uploaded By