Submission #425446

# Submission time Handle Problem Language Result Execution time Memory
425446 2021-06-13T03:58:07 Z errorgorn Orchard (NOI14_orchard) C++17
25 / 25
188 ms 11604 KB
#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

orchard.cpp: In function 'int main()':
orchard.cpp:18:7: 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:24:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |    scanf("%d",&c);
      |    ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 460 KB Output is correct
2 Correct 4 ms 460 KB Output is correct
3 Correct 2 ms 448 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 124 ms 11528 KB Output is correct
2 Correct 122 ms 11604 KB Output is correct
3 Correct 144 ms 11520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 2168 KB Output is correct
2 Correct 24 ms 2248 KB Output is correct
3 Correct 26 ms 2220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 332 KB Output is correct
2 Correct 6 ms 428 KB Output is correct
3 Correct 6 ms 484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 188 ms 5188 KB Output is correct
2 Correct 182 ms 5284 KB Output is correct
3 Correct 177 ms 5212 KB Output is correct