답안 #170351

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
170351 2019-12-24T20:24:29 Z ngmh 과수원 (NOI14_orchard) C++11
25 / 25
294 ms 18168 KB
#include <bits/stdc++.h>
using namespace std;

long long n, m, o, s, ans = INT_MIN;
int main(){
	cin >> n >> m;
	long long a[n+5][m+5], ss[m+5];
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> a[i][j];
			if(a[i][j]) o++;
			else a[i][j] = -1;
		}
	}
	for(int i = 1; i <= n; i++){
		memset(ss, 0, sizeof(ss));
		for(int j = i; j <= n; j++){
			s = 0;
			for(int k = 1; k <= m; k++){
				ss[k] += a[j][k];
				s = max(ss[k], s+ss[k]);
				ans = max(s, ans);
			}
		}
	}
	cout << o-ans; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 760 KB Output is correct
2 Correct 6 ms 632 KB Output is correct
3 Correct 6 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 268 ms 17936 KB Output is correct
2 Correct 267 ms 17964 KB Output is correct
3 Correct 278 ms 18168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 3192 KB Output is correct
2 Correct 55 ms 3028 KB Output is correct
3 Correct 55 ms 3104 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 10 ms 504 KB Output is correct
3 Correct 11 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 279 ms 7964 KB Output is correct
2 Correct 278 ms 7784 KB Output is correct
3 Correct 294 ms 7852 KB Output is correct