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 1910. Titan Ruins: Hidden Entrance
- URAL - 2018 The Debut Album
- Ural 1068
- ural1100--Final Standings--数据结构--结构体排序
- ural 1869. New Year Cruise
- URAL 1005 Stone Pile
- URAL 1009
- URAL 1057 数位DP
- UVA - 10780 Again Prime? No Time.
- URAL 1019 - Line Painting(线段树)
- ural 1108
- ural 1123
- ural 1066 uva 1555
- ural 1069
- ural 1160
- ural 1221
- ural 1200
- ural 1233
- ural 1250
- ural 1864