#P3946. Kotori's Snowy Journey

    ID: 17194 Type: Default 1000ms 256MiB

Kotori's Snowy Journey

Kotori's Snowy Journey

During the winter of 2017, Kotori sets out from a dessert shop (node s) to go home (node t) in snowy Akihabara. However, the weather is harsh: at every second, the snow depth increases by \(q\) millimeters. Initially, each of the \(n\) locations has a snow depth \(h_i\) (in millimeters). Moreover, every location (except for the dessert shop and home) has a snow limit \(l_i\). If upon arrival the snow depth, calculated as \(h_i + q \times (arrival\ time)\), exceeds \(l_i\) (i.e. if \(h_i + q \times (arrival\ time) > l_i\)), Kotori gets stranded at that location.

There are \(m\) bidirectional roads connecting these locations; each road connects two different locations and has a length (in meters). Kotori walks at a speed of 1 m/s. She aims to reach home within \(g\) seconds. If she cannot make it in time or if she is stranded en route, she will end up having wtnap as her dessert.

Task: Determine the minimum time Kotori can safely reach home. If it is not possible for Kotori to safely reach home within \(g\) seconds, output wtnap.

inputFormat

The input is given as follows:

  1. The first line contains six integers: \(n\), \(m\), \(q\), \(g\), \(s\), and \(t\). Here, \(n\) is the number of locations, \(m\) is the number of roads, \(q\) is the snowfall rate (in millimeters per second), \(g\) is the time limit in seconds, \(s\) is the index of the dessert shop, and \(t\) is the index of Kotori's home.
  2. The second line contains \(n\) integers: \(h_1, h_2, ..., h_n\), where \(h_i\) is the initial snow depth at location \(i\) (in millimeters).
  3. The third line contains \(n\) integers: \(l_1, l_2, ..., l_n\), where \(l_i\) is the snow limit for location \(i\) (in millimeters).
  4. Each of the next \(m\) lines contains three integers: \(u\), \(v\), and \(w\), meaning that there is a bidirectional road connecting locations \(u\) and \(v\) with length \(w\) meters.

Note: At the dessert shop (\(s\)) and at home (\(t\)), the snow limit check is not applied.

outputFormat

If Kotori can safely reach home within \(g\) seconds, output the minimum time (in seconds) required. Otherwise, output wtnap.

sample

3 2 1 10 1 3
0 0 0
100 1 100
1 2 1
2 3 1
2