1
0
mirror of https://github.com/renbaoshuo/202401-programming-assignments.git synced 2024-11-23 21:58:41 +00:00
202401-programming-assignments/【实践课外】7.数组1/7-7 装箱问题.c

28 lines
421 B
C
Raw Normal View History

2024-11-06 03:38:23 +00:00
#include <stdio.h>
int n, box[1005];
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
int x;
scanf("%d", &x);
for (int j = 1; j <= n; j++) {
if (box[j] + x <= 100) {
printf("%d %d\n", x, j);
box[j] += x;
break;
}
}
}
while (box[n] == 0) n--;
printf("%d\n", n);
return 0;
}