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

28 lines
421 B
C

#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;
}