이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define mnto(x, y) x = min(x, (__typeof__(x)) y)
#define mxto(x, y) x = max(x, (__typeof__(x)) y)
#define REP(i, s, e) for (int i = s; i < e; i++)
#define RREP(i, s, e) for (int i = s; i >= e; i--)
typedef long long ll;
typedef long double ld;
#define MP make_pair
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
#define MT make_tuple
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define pb emplace_back
typedef vector<int> vi;
typedef vector<ii> vii;
#define INF 1000000005
#define LINF 1000000000000000005
#define MOD 1000000007
#define MAXN 155
#define MAXM 1000005
int n, m;
int cols[MAXN][MAXM];
int ans;
int sum(int c, int t, int b) {
return cols[b][c] - cols[t - 1][c];
}
int main() {
scanf("%d%d", &n, &m);
REP (i, 1, n + 1) {
REP (j, 1, m + 1) {
scanf("%d", &cols[i][j]);
ans += cols[i][j];
cols[i][j] += cols[i - 1][j];
}
}
vector<vector<int>> dp(n + 5, vector<int>(n + 5, 0));
int sub = INF;
REP (k, 1, m + 1) {
REP (i, 1, n + 1) {
REP (j, i, n + 1) {
dp[i][j] = min(dp[i][j], 0) - 2 * sum(k, i, j) + (j - i + 1);
mnto(sub, dp[i][j]);
}
}
}
ans += sub;
printf("%d\n", ans);
return 0;
}
/*
5 7
0 0 1 0 0 1 0
0 1 1 1 1 1 0
0 1 1 0 0 1 0
0 1 1 1 1 1 0
0 0 1 0 0 1 0
*/
컴파일 시 표준 에러 (stderr) 메시지
orchard.cpp: In function 'int main()':
orchard.cpp:37:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
37 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
orchard.cpp:40:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
40 | scanf("%d", &cols[i][j]);
| ~~~~~^~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |