Submission #72497906
Source Code Expand
Copy
#include <stdio.h>#define INF (100LL * 1000 * 1000 * 10)int m, n;int a, b;int c[1024][1024];long long sum[1024][1024];int main(void) {int i, j;long long ans = INF;if (scanf("%d%d", &m, &n) != 2) return 1;if (scanf("%d%d", &a, &b) != 2) return 1;for (i = 1; i <= n; i++) {for (j = 1; j <= m; j++) {if (scanf("%d", &c[i][j]) != 1) return 1;sum[i][j] = sum[i][j - 1] + (c[i][j] < 0 ? INF : c[i][j]);}for (j = 1; j <= m; j++) {
#include <stdio.h>
#define INF (100LL * 1000 * 1000 * 10)
int m, n;
int a, b;
int c[1024][1024];
long long sum[1024][1024];
int main(void) {
int i, j;
long long ans = INF;
if (scanf("%d%d", &m, &n) != 2) return 1;
if (scanf("%d%d", &a, &b) != 2) return 1;
for (i = 1; i <= n; i++) {
for (j = 1; j <= m; j++) {
if (scanf("%d", &c[i][j]) != 1) return 1;
sum[i][j] = sum[i][j - 1] + (c[i][j] < 0 ? INF : c[i][j]);
}
for (j = 1; j <= m; j++) {
sum[i][j] += sum[i - 1][j];
}
}
for (i = b; i <= n; i++) {
for (j = a; j <= m; j++) {
long long candidate = sum[i][j] - sum[i][j - a] - sum[i - b][j] + sum[i - b][j - a];
if (candidate < ans) ans = candidate;
}
}
printf("%d\n", (int)ans);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | mall - ショッピングモール (Mall) |
| User | mikecat |
| Language | C23 (GCC 14.2.0) |
| Score | 100 |
| Code Size | 765 Byte |
| Status | AC |
| Exec Time | 48 ms |
| Memory | 13724 KiB |
Judge Result
| Set Name | Set01 | Set02 | Set03 | Set04 | Set05 | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 20 / 20 | 20 / 20 | 20 / 20 | 20 / 20 | 20 / 20 | ||||||||||
| Status |
|
|
|
|
|
| Set Name | Test Cases |
|---|---|
| Set01 | 01 |
| Set02 | 02 |
| Set03 | 03 |
| Set04 | 04 |
| Set05 | 05 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01 | AC | 1 ms | 1644 KiB |
| 02 | AC | 45 ms | 13104 KiB |
| 03 | AC | 45 ms | 13024 KiB |
| 04 | AC | 45 ms | 13716 KiB |
| 05 | AC | 48 ms | 13724 KiB |