AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

DAPC21-043.Candy Contribution

Medium · 1 s · 256 MB

  • icpc
  • dapc
  • 2021

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?

Giriş formatı

The input consists of:

• One line containing two integers nnn (2≤n≤1⋅1052\leq n\leq 1\cdot 10^52≤n≤1⋅105), the number of countries, and mmm (1≤m≤2⋅1051 \leq m \leq 2\cdot 10^51≤m≤2⋅105), the number of borders.

• One line containing three integers sss (1≤s≤n1\leq s\leq n1≤s≤n), the country where you won the lottery, ttt (1≤t≤n1 \leq t \leq n1≤t≤n, t≠st\neq st=s), your home country and ccc (1≤c≤1091\leq c \leq 10^91≤c≤109) the number of candies you won in the lottery.

• Then follow mmm lines containing three integers u,vu, vu,v (1≤u,v≤n1\leq u, v \leq n1≤u,v≤n, u≠vu\neq vu=v) and ppp (0≤p≤1000 \leq p \leq 1000≤p≤100) where ppp is the percentage of tax you have to pay when travelling from country uuu to vvv or vice versa.

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

Çıxış formatı

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

Qeyd

Source: Delft Algorithm Programming Contest 2021 · Author: Ruben Brokkelkamp · License: CC BY-SA 4.0 · Original: https://dapc.wisv.ch · Statement adapted for AlgoLens and shared under the same license. · 12 of the 33 original test cases (the largest) are omitted here to keep the problem lightweight.

Nümunələr

Giriş #1

4 4
1 4 1000
1 2 25
2 4 10
1 3 4
3 4 30

Çıxış #1

675

Giriş #2

5 5
1 5 6
1 2 17
2 5 19
1 3 1
3 4 1
4 5 1

Çıxış #2

3