# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
265286 | T0p_ | 과수원 (NOI14_orchard) | C++14 | 427 ms | 25824 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int dp[155][155][2];
int main()
{
int n, m;
scanf(" %d %d",&n,&m);
int arr[n+5][m+5];
memset(arr, 0, sizeof arr);
for(int i=1 ; i<=n ; i++)
for(int j=1 ; j<=m ; j++)
{
scanf(" %d",&arr[i][j]);
arr[i][j] += arr[i-1][j] + arr[i][j-1] - arr[i-1][j-1];
}
int ans = 1e9;
for(int sz=1 ; sz<=n ; sz++)
for(int i=1 ; i<=n ; i++)
{
int j = i+sz-1;
if(j > n) break ;
for(int k=1 ; k<=m ; k++)
{
dp[i][j][k%2] = min(dp[i][j][(k-1)%2], arr[j][k-1] - arr[i-1][k-1]) + sz - arr[j][k] + arr[j][k-1] + arr[i-1][k] - arr[i-1][k-1];
ans = min(ans, dp[i][j][k%2] + arr[j][m] - arr[j][k] + arr[i-1][k] + arr[n][m] - arr[j][m]);
}
}
printf("%d\n",ans);
return 0;
}
// dp[i][j][k] -> row ith to row jth, col 1st to col kth and end the second area on col kth
/*
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) 메시지
# | 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... |