RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
USACO0590

Train Scheduling

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

의견: 0

설명

*Note: The memory limit for this problem is 512MB, twice the default.*

Bessie has taken on a new job as a train dispatcher! There are two train
stations: \(A\) and \(B\). Due to budget constraints, there is only a single track
connecting the stations. If a train departs a station at time \(t\), then it will
arrive at the other station at time \(t+T\) (\(1\le T\le 10^{12}\)).

There are \(N\) (\(1\le N\le 5000\)) trains whose departure times need to be
scheduled. The \(i\)th train must leave station \(s_i\) at time \(t_i\) or later
(\(s_i\in \{A, B\}, 0\le t_i\le 10^{12}\)). It is not permitted to have trains
going in opposite directions along the track at the same time (since they would
crash). However, it is permitted to have many trains on the track going in the
same direction at the same time (assume trains have negligible size).

Help Bessie schedule the departure times of all trains such that there are no
crashes and the total delay is minimized. If train \(i\) is scheduled to leave at
time \(a_i\ge t_i\), the total delay is defined as \(\sum_{i=1}^N(a_i-t_i)\).

Problem credits: Brandon Wang

제약

SCORING

  • Inputs 5-6: \(N \le 15\)
  • Inputs 7-10: \(N \le 100\)
  • Inputs 11-14: \(N \le 500\)
  • Inputs 15-18: \(N\le 2000\)
  • Inputs 19-24: No additional constraints

Problem credits: Brandon Wang

입력 형식

The first line contains \(N\) and \(T\).

Then \(N\) lines follow, where the \(i\)th line contains the station \(s_i\) and
time \(t_i\) corresponding to the \(i\)th train.

출력 형식

The minimum possible total delay over all valid schedules.

예제 1
입력
1 95
B 63
출력
0
설명

The only train leaves on time.

예제 2
입력
4 1
B 3
B 2
A 1
A 3
출력
1
설명

There are two optimal schedules. One option is to have trains \(2,3,4\) leave on
time and train \(1\) leave after a one-minute delay. Another is to have trains
\(1,2,3\) leave on time and train \(4\) leave after a one-minute delay.

예제 3
입력
4 10
A 1
B 2
A 3
A 21
출력
13
설명

The optimal schedule is to have trains \(1\) and \(3\) leave on time, train \(2\)
leave at time \(13\), and train \(4\) leave at time \(23\). The total delay is
\(0+11+0+2=13\).

예제 4
입력
8 125000000000
B 17108575619
B 57117098303
A 42515717584
B 26473500855
A 108514697534
B 110763448122
B 117731666682
A 29117227954
출력
548047356974
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2023-2024 > December > Platinum

태그

평가 및 의견

Train Scheduling

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

Log in to rate problems.

개별 의견

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

풀이 제출

Train Scheduling

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