B - Nuts Editorial by en_translator


Check all the trees just as the problem statement instructs. Appropriately combine for statement and if statement.

Sample code (c)

int a[200010];
int main(){
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d",&a[i]);
  int ans=0;
  for(int i=0;i<n;i++){
    if(a[i]>10)ans+=a[i]-10;
  }
  printf("%d",ans);
}

Sample code (Python)

N=int(input())
A=list(map(int,input().split()))
ans=0
for a in A:
  if a>10: ans+=a-10
print(ans)

posted:
last update: