RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0359 파일 입출력

Shortcut

Gold I 골드 I
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Every evening, Farmer John rings a giant bell that summons his cows to the barn
for dinner. Eager to get to the barn as quickly as possible, they all follow
the shortest possible route to get there.

The farm is described by a set of \(N\) fields (\(1 \leq N \leq 10,000\)),
conveniently numbered \(1 \ldots N\), with the barn residing in field 1. The
fields are connected by a set of \(M\) bidirectional trails
(\(N-1 \leq M \leq 50,000\)). Each trail has a travel time associated with it,
and there is a path from every field to the barn using some set of trails.

Field \(i\) contains \(c_i\) cows. Upon hearing the dinner bell, these cows all
walk to the barn along a route that takes the minimum amount of time. If there
are several routes tied for the minimum time, the cows take whichever of these
is "lexicographically" smallest (i.e., they break ties between two routes by
favoring the one using the lower-indexed field at the first place where the
routes differ, so for example a path that visits fields 7, 3, 6, 1 would be
preferable to one that visits 7, 5, 1, assuming both had the same travel time).

Farmer John is worried about the barn being far away from some fields. He adds
up the travel time experienced by each cow, summed over all the cows, calling
this number the total travel time. He would like to reduce this number as much
as possible by adding one extra "shortcut" trail which has a travel time of \(T\)
(\(1 \leq T \leq 10,000\)), from the barn (field 1) to some other field of his
choosing. If a cow stumbles upon the shortcut trail while traveling along her
usual path to the barn, she will take it if it gets her to the barn faster.
Otherwise, a cow will follow her usual route, even if it might have been
possible to use the shortcut to improve her travel time.

Please help Farmer John determine the greatest possible amount of decrease in
total travel time he can achieve by adding his shortcut trail.

Problem credits: Brian Dean

제약

Problem credits: Brian Dean

입력 형식

The first line of input contains \(N\), \(M\), and \(T\). The next line contains
\(N\) integers \(c_1 \ldots c_N\), each in the range \(0 \ldots 10,000\). The next \(M\)
lines each describe a trail using three integers \(a\), \(b\), and \(t\), where the
trail connects fields \(a\) and \(b\) and has travel time \(t\). All travel times are
in the range \(1 \ldots 25,000\).

출력 형식

Please output the largest possible reduction in total travel time Farmer John
can achieve.

파일 입력 / 출력
이 문제는 표준 입출력을 사용하지 않습니다. 프로그램은 다음 파일을 읽고 써야 합니다:
입력을 읽을 파일 shortcut.in
출력을 쓸 파일 shortcut.out
예제 1
입력
5 6 2
1 2 3 4 5
1 2 5
1 3 3
2 4 3
3 4 5
4 5 2
3 5 7
출력
40
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2018-2019 > January > Gold

태그

평가 및 의견

Shortcut

개요
출제자 난이도 Gold I 골드 I 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Shortcut

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8