Under construction

Still being built. Things may change

Sinchon Defense HQ Escape

Time limit1sMemory limit1024 MB

Summary
Route people from building 1 to exit building N through corridors that catch fire and collapse, maximizing evacuees first, then escape time, then fatigue.
Level

Hard8 of 10

Topics
Graph, Shortest path, BFS
Solved
No attempts yet

Problem

On August 21, 2021, the Sinchon Defense Headquarters was attacked by an unknown organization. The headquarters repelled the attack with a strong response, but the organization did not forget and waited for a chance to strike again. On February 25, 2023, after two years of waiting, the organization hit the headquarters building directly, and a fire broke out inside it. As the commander of the Sinchon Defense Headquarters, you want to evacuate as many people as possible from the fire.

The headquarters is a connected graph of NN buildings and MM two-way corridors that link them. The buildings are numbered from 11 to NN. Several corridors may connect the same pair of buildings. The fire starts in building 11, and the exit is in building NN. Leaving through building NN takes so little time that it can be treated as 00. One hour after a building catches fire, it passes the fire to every connected building that has not yet caught fire through a corridor. A building collapses completely TT hours after it catches fire, and no one can pass through it. People cannot enter a corridor connected to a building, or the exit, even at exactly TT hours after the fire starts.

Initially, building ii has PiP_i people. People move through corridors. Each corridor has a capacity cc, which is the maximum number of people that can enter it in one hour, a travel time tt, and a fatigue value xx, which increases by 11 for each person entering it.

Your goal is to evacuate the largest possible number of people in the shortest possible escape time with the smallest total fatigue. These goals are ranked in that order: number of people, then escape time, then fatigue. The escape time is the time when the last person escapes, and it is 00 if no one escapes.

Input

The first line contains the number of buildings NN, the number of corridors MM, and the time TT it takes for a building to collapse completely, separated by spaces. (2≤N≤50;1≤T≤50;1≤M≤2002 \leq N \leq 50; 1 \leq T \leq 50; 1 \leq M \leq 200)

The second line contains the number of people PiP_i in building ii, separated by spaces. (0≤Pi≤100;∑i=1NPi≤1000 \leq P_i \leq 100; \sum_{i=1}^N P_i \leq 100)

From the third line, MM lines follow. The ii-th line contains ui,vi,ci,ti,xiu_i, v_i, c_i, t_i, x_i, separated by spaces.

This means that the corridor connecting building uiu_i and building viv_i has the values cic_i, tit_i, and xix_i described above. (1≤ui,vi≤N;1≤ci,ti,xi≤100;ui≠vi1 \leq u_i, v_i \leq N; 1 \leq c_i, t_i, x_i \leq 100; u_i \neq v_i)

All given numbers are integers.

Output

Print the maximum number of people that can be evacuated, the shortest escape time for evacuating that maximum number of people, and the minimum total fatigue when evacuating the maximum number of people in the shortest escape time, separated by spaces on one line.

Examples2

  1. Example 1

    Input
    5 6 3
    3 0 2 1 0
    1 2 3 1 3
    1 3 2 3 1
    2 4 2 1 2
    2 5 2 2 4
    3 5 1 2 2
    4 5 2 1 1
    
    Expected output
    6 3 24
    
  2. Example 2

    Input
    3 3 10
    50 0 0
    1 2 50 1 1
    2 3 50 20 2
    1 3 1 1 50
    
    Expected output
    10 10 500