Problem:
Score : 100 points

Problem Statement

N of us are going on a trip, by train or taxi.

The train will cost each of us A yen (the currency of Japan).

The taxi will cost us a total of B yen.

How much is our minimum total travel expense?

Constraints

All values in input are integers.

1 \leq N \leq 20

1 \leq A \leq 50

1 \leq B \leq 50

Input

Input is given from Standard Input in the following format:

N A B

Output

Print an integer representing the minimum total travel expense.

Sample Input 1

4 2 9

Sample Output 1

8

The train will cost us 4 \times 2 = 8 yen, and the taxi will cost us 9 yen, so the minimum total travel expense is 8 yen.

Sample Input 2

4 2 7

Sample Output 2

7

Sample Input 3

4 2 8

Sample Output 3

8

Solution in C (GCC 5.4.1) (judge verdict: Wrong Answer)

#include<stdio.h>
int main(void)
{
  int n;
  long a[100001];
  long b[100000];
  int i;
  int sum=0;
    
  scanf("%d",&n);
  for(i=0;i<n+1;i++)
    scanf("%d",&a[i]);
  
  for(i=0;i<n;i++)
    scanf("%d",&b[i]);
  
  for(i=0;i<n+1;i++)
  {
    if(a[i]>=b[i])
    {
      sum+=b[i];
      b[i]=0; 
    }
   
    else
    {
      sum+=a[i];
      b[i]=b[i]-a[i];
      a[i]=0;
      if(i==n)
        break;
      if(a[i+1]>=b[i])
      {
        sum+=b[i];
        b[i]=0;
        
      }
      else
      {
        sum+=a[i+1];
        a[i+1]=0;
        b[i]-=a[i+1];
      }
    }
  }
  
  printf("%d",sum);
  
  return 0;
}