您的位置:首页 > 其它

URAL 1279 Warehouse

2015-11-06 09:11 405 查看
#include <stdio.h>
#define MAX_HIGHT 1000

int numOfRows, numOfColumns, numOfNewContainers;
int sections[MAX_HIGHT + 1];
int result;

int main(){

scanf("%d%d%d", &numOfRows, &numOfColumns, &numOfNewContainers);
int row, column, initailHight;
for (row = 1; row <= numOfRows; row++){
for (column = 1; column <= numOfColumns; column++){
scanf("%d", &initailHight);
sections[initailHight]++;
}
}

int preNewContainersPlaced = 0;
int hight, newContainersPlaced;
for (hight = 1; hight <= MAX_HIGHT; hight++){
//往原来高度为hight的section都放上一个container
newContainersPlaced = preNewContainersPlaced + sections[hight];
if (newContainersPlaced < numOfNewContainers){
preNewContainersPlaced = newContainersPlaced;
sections[hight + 1] += sections[hight];
} else if (newContainersPlaced == numOfNewContainers){
result = hight + 1;
break;
} else {
result = hight;
break;
}
}

printf("%d\n", result);

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  URAL 1279 Warehouse