제출 #516347

#제출 시각아이디문제언어결과실행 시간메모리
516347Jomnoi과수원 (NOI14_orchard)C++17
13 / 25
331 ms8496 KiB
#include <bits/stdc++.h> #define DEBUG 0 using namespace std; const int N = 160; const int M = 5e3 + 10; const int INF = 1e9 + 7; int a[N][M]; int dp[M]; int get(int x1, int x2, int y1, int y2) { return a[x2][y2] - a[x1 - 1][y2] - a[x2][y1 - 1] + a[x1 - 1][y1 - 1]; } int main() { int n, m; scanf(" %d %d", &n, &m); int sum = 0; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { scanf(" %d", &a[i][j]); if(a[i][j] == 0) { a[i][j] = 1; } else { sum++; a[i][j] = -1; } a[i][j] += a[i - 1][j] + a[i][j - 1] - a[i - 1][j - 1]; } } int ans = INF; dp[m + 1] = INF; for(int i = 1; i <= n; i++) { for(int j = i; j <= n; j++) { for(int k = m; k >= 1; k--) { dp[k] = min(dp[k + 1], get(i, j, 1, k)); } if(DEBUG) { cout << "Debugging : " << i << " " << j << endl; for(int k = 1; k <= m; k++) { cout << dp[k] << " "; } cout << endl; } for(int k = 1; k <= m; k++) { ans = min(ans, sum + dp[k] - get(i, j, 1, k - 1)); } } } cout << ans; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

orchard.cpp: In function 'int main()':
orchard.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf(" %d %d", &n, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~
orchard.cpp:23:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |             scanf(" %d", &a[i][j]);
      |             ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...