# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425446 | errorgorn | Orchard (NOI14_orchard) | C++17 | 188 ms | 11604 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> ii;
int n,m,k,c,i,mmm;
vector<int> v[155];
int sum(int a,int b){
int mm=0,cm=0;
for (int x=0;x<m;x++){
i=v[b][x]-v[a][x];
cm=max(cm+i,i);
mm=max(mm,cm);
}
return mm;
}
int main(){
scanf("%d%d",&n,&m);
for (int x=0;x<m;x++){
v[0].push_back(0);
}
for (int x=1;x<=n;x++){
for (int y=0;y<m;y++){
scanf("%d",&c);
i=v[x-1][y];
if (c==1) i++,k++;
else i--;
v[x].push_back(i);
}
}
/*for (int x=0;x<=n;x++){
for (int y=0;y<m;y++){
printf("%d ",v[x][y]);
}
printf("\n");
}*/
for (int x=0;x<n;x++){
for (int y=x+1;y<=n;y++){
mmm=max(mmm,sum(x,y));
}
}
printf("%d\n",k-mmm);
}
Compilation message (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... |