답안 #676469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676469 2022-12-31T03:32:42 Z penguin133 과수원 (NOI14_orchard) C++17
25 / 25
191 ms 10060 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
	int r,c;
	cin >> r >> c;
	int g[r][c];
	long long a=0,b=0;
	string s;
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin >> g[i][j];
			if(g[i][j] == 1){
				b++;
			}
			else{
				g[i][j] = -1;
			}
		}
	}
	long long cnt= 0;
	long long maxi = 0;
	int d = -1;
	int e = -1;
	int d1=-1, e1 = -1;
	long long mini = 1e18 + 5;
	for(int i=0;i<r;i++){
		int cnt2[c];
		for(int x=0;x<c;x++){
			cnt2[x] = g[i][x];
		}
		for(int j=i;j<r;j++){
			if(j != i){
				for(int x=0;x<c;x++){
					cnt2[x] += g[j][x];
				}
			}
			cnt = 0;
			for(int k=0;k<c;k++){
				cnt += cnt2[k];
				if(cnt > maxi){
					maxi = cnt;
				}
				if(cnt < 0){
					cnt = 0;
				}
			}
		}
	}
	cout << b - maxi;
}

Compilation message

orchard.cpp: In function 'int main()':
orchard.cpp:8:12: warning: unused variable 'a' [-Wunused-variable]
    8 |  long long a=0,b=0;
      |            ^
orchard.cpp:23:6: warning: unused variable 'd' [-Wunused-variable]
   23 |  int d = -1;
      |      ^
orchard.cpp:24:6: warning: unused variable 'e' [-Wunused-variable]
   24 |  int e = -1;
      |      ^
orchard.cpp:25:6: warning: unused variable 'd1' [-Wunused-variable]
   25 |  int d1=-1, e1 = -1;
      |      ^~
orchard.cpp:25:13: warning: unused variable 'e1' [-Wunused-variable]
   25 |  int d1=-1, e1 = -1;
      |             ^~
orchard.cpp:26:12: warning: unused variable 'mini' [-Wunused-variable]
   26 |  long long mini = 1e18 + 5;
      |            ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 10060 KB Output is correct
2 Correct 141 ms 10060 KB Output is correct
3 Correct 136 ms 10060 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 1816 KB Output is correct
2 Correct 28 ms 1824 KB Output is correct
3 Correct 27 ms 1816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 308 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 6 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 189 ms 4600 KB Output is correct
2 Correct 191 ms 4604 KB Output is correct
3 Correct 185 ms 4692 KB Output is correct