标签:
Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1987 Accepted Submission(s): 552
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int a[10001][100]; int m,n,p; int fun(int m) { int cnt=0; for(int i=n-1;m>=1&&i>=0;i--) { if(a[m-1][i]==0) cnt++; else break; } return cnt; } int cmp(const int x,const int y){return x>y;} int main() { int b[10001]; int c[10001]; while(cin>>m>>n>>p) { int count=0; int cnt=0; int count_0=0; int sum=0; for(int i=0;i<m;i++) { for(int j=0;j<n;j++) {cin>>a[i][j]; if(a[i][j]==0) count_0++;} if(a[i][0]==0&&a[i][1]==0) b[count++]=i; } for(int i=0;i<count;i++) { c[cnt++]=(fun(b[i])+2); } sort(c,c+cnt,cmp); for(int i=0;i<p-1;i++) { sum+=c[i]; } sum+=fun(m); sum+=2; cout<<(count_0-sum)<<endl; } return 0; }
标签:
原文地址:http://www.cnblogs.com/hellohacker/p/5866477.html