题解 | #称砝码#
称砝码
https://www.nowcoder.com/practice/f9a4c19050fc477e9e27eb75f3bfd49c
#include <stdio.h> int main() { int b[200000]={0}; int n,i,j,k,temp=0,a[10][2]={0}; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&a[i][0]); } for(i=0;i<n;i++){ scanf("%d",&a[i][1]); } int high=0,num=0; for(i=0;i<n;){ for(j=0;j<=high;j++){ num=a[i][0]+b[j]; for(k=0;k<=high;k++){ if(num==b[k]) break; } if(k==high+1){ temp++; b[high+temp]=num; } } high=high+temp;temp=0; if((--a[i][1])<=0) i++; } printf("%d",high+1); return 0; }