Click Here to go back to the homepage.

Parking Solution:


import java.util.Scanner;

public class Kattis {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int d, e, f, g, h, i;
    int[] cost = {0, sc.nextInt(), sc.nextInt(), sc.nextInt()};
    d = sc.nextInt();
    e = sc.nextInt();
    f = sc.nextInt();
    g = sc.nextInt();
    h = sc.nextInt();
    i = sc.nextInt();
    int curr = 0;
    int sum = 0;
    for (int j = 1; j < 100; j++) {
      if(j == d)
        curr++;
      if(j == f)
        curr++;
      if(j == h)
        curr++;
      if(j == e)
        curr--;
      if(j == g)
        curr--;
      if(j == i)
        curr--;
      sum+=curr * cost[curr];
    }
    System.out.println(sum);
  }
}