# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
156981 |
2019-10-08T17:58:43 Z |
brcode |
Orchard (NOI14_orchard) |
C++14 |
|
359 ms |
25820 KB |
#include <iostream>
using namespace std;
int ans,cnt;
int main(){
int n,m;
cin>>n>>m;
int dp[n+5][m+5];
int arr[n+5][m+5];
for(int i=0;i<=n+1;i++){
for(int j=0;j<=m+1;j++){
dp[i][j] = 0;
arr[i][j] = 0;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
char x;
cin>>x;
if(x=='0'){
arr[i][j] = -1;
}else{
arr[i][j] = 1;
cnt++;
}
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
dp[i][j] = dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+arr[i][j];
}
}
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
int pos = m;
for(int k=m;k>=1;k--){
if(dp[j][k]-dp[i-1][k]>dp[j][pos]-dp[i-1][pos]){
pos = k;
}
ans = max(ans, dp[j][pos]-dp[j][k-1]-dp[i-1][pos]+dp[i-1][k-1]);
}
}
}
cout<<cnt-ans<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
252 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
888 KB |
Output is correct |
2 |
Correct |
5 ms |
760 KB |
Output is correct |
3 |
Correct |
5 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
181 ms |
25720 KB |
Output is correct |
2 |
Correct |
184 ms |
25820 KB |
Output is correct |
3 |
Correct |
188 ms |
25756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
3960 KB |
Output is correct |
2 |
Correct |
37 ms |
3832 KB |
Output is correct |
3 |
Correct |
37 ms |
3836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
10 ms |
504 KB |
Output is correct |
3 |
Correct |
10 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
250 ms |
7908 KB |
Output is correct |
2 |
Correct |
359 ms |
7900 KB |
Output is correct |
3 |
Correct |
254 ms |
7928 KB |
Output is correct |