This page is still under construction.

Parts of this page are still being built. What you see may change.

Candy Contribution

Time limit3sMemory limit1024 MB

Summary
Given an undirected graph where crossing a border costs a percentage of candies rounded up, find the maximum candies reachable from start to home.
Level

Medium6 of 10

Topics
Graph, Shortest path, Greedy, Math
Solved
No attempts yet

Problem

While you were out travelling, you won the lottery. As it happened, the top prize of this lottery was not cash, but candies! Now you are stuck with a big pile of candies which you would like to take home. Fortunately, you have been able to acquire a truck, so now all you have to do is drive home.

Going from one country to another with such a big pile of candies in your truck is not allowed without paying some taxes. And because everybody likes candies, you are allowed to pay these taxes with candies.

After searching a bit on the internet, you have found a list that tells you exactly which borders you can cross with a truck and for each such border what percentage of tax you have to pay to cross it. You cannot pay with fractional candies and the candies are quite nice, so customs will always round up. You only have to pay taxes on the number of candies you bring across the border.

What is the maximum number of candies you can bring home?

Input

The input consists of:

  • One line containing two integers nn (2≤n≤1⋅1052\leq n\leq 1\cdot 10^5), the number of countries, and mm (1≤m≤2⋅1051 \leq m \leq 2\cdot 10^5), the number of borders.
  • One line containing three integers ss (1≤s≤n1\leq s\leq n), the country where you won the lottery, tt (1≤t≤n1 \leq t \leq n, t≠st\neq s), your home country and cc (1≤c≤1091\leq c \leq 10^9) the number of candies you won in the lottery.
  • Then follow mm lines containing three integers u,vu, v (1≤u,v≤n1\leq u, v \leq n, u≠vu\neq v) and pp (0≤p≤1000 \leq p \leq 100) where pp is the percentage of tax you have to pay when travelling from country uu to vv or vice versa.

It is guaranteed you can drive home with your truck, and that each pair of countries is listed at most once.

Output

Output the maximum number of candies you can arrive home with.

Examples2

  1. Example 1

    Input
    4 4
    1 4 1000
    1 2 25
    2 4 10
    1 3 4
    3 4 30
    
    Expected output
    675
    
  2. Example 2

    Input
    5 5
    1 5 6
    1 2 17
    2 5 19
    1 3 1
    3 4 1
    4 5 1
    
    Expected output
    3