1 solutions
-
1
送命二维前缀和注意题目要的是左上角的坐标
#include <cstdio> #include <algorithm> #include <cmath> int n, m, c, ans=-999999999, x, y; int a[1005][1005], s[1005][1005]; int main() { std::cin >> n >> m >> c; for(int i = 1;i <= n; i ++) { for(int j = 1;j <= m;j ++) { scanf("%d", &a[i][j]); s[i][j] = a[i][j] + s[i-1][j] + s[i][j-1] - s[i-1][j-1]; } } for(int i = c;i <= n; i ++) { for(int j = c;j <= m; j ++) { int land=s[i][j] - s[i - c][j] - s[i][j - c] + s[i - c][j - c]; if(land > ans) { ans = land; x = i; y = j; } } } std::cout << x - c + 1 << " " << y - c + 1; return 0; }
- 1
Information
- ID
- 953
- Time
- 1000ms
- Memory
- 125MiB
- Difficulty
- 2
- Tags
- # Submissions
- 5
- Accepted
- 2
- Uploaded By