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

Bike Parking

설명

Sanne recently conceived a lucrative business idea: renting out premium bike parking at the Eindhoven train station. To maximize her profits, she divided the bike parking slots into \(N\) different tiers, numbered from \(0\) to \(N-1\). Tier 0, the premium tier, is located very close to the train platforms. Higher-numbered tiers consist of parking slots that are worse (the higher the tier, the worse the slot). The number of slots in tier \(t\) is \(x_t\).

Users parking their bikes are assigned their parking slot via an app. Each user has a subscription level and expects a parking slot in the corresponding tier. However, the terms of service do not guarantee users a slot in their respective tier.

If a user with subscription level \(s\) is assigned a slot in tier \(t\), then one of the following three things happens:
- If \(t < s\), the user will be happy and upvote the app.
- If \(t = s\), the user will be satisfied and will not do anything.
- If \(t > s\), the user will be angry and downvote the app.

Today, Sanne's app has \(y_0+y_1+\ldots+y_{N-1}\) users, where \(y_s\) is the number of users with subscription level \(s\). She needs your help to assign the users to the parking slots. Each user should get exactly one slot. No slot can be assigned to more than one user, but it is okay for some parking slots to not be assigned to any users. Furthermore, the total number of users does not exceed the total number of available parking slots.

Sanne wants to maximize the rating of her app. Let \(U\) be the number of upvotes and \(D\) be the number of downvotes. Your task is to maximize \(U-D\).

(An illustrative figure from the official statement is omitted here.)

제약
  • \(1 \leq N \leq 3 \cdot 10^5\).
  • \(0 \leq x_i, y_i \leq 10^9\) for \(i = 0,1,\ldots , N-1\).
  • \(y_0+y_1+\ldots + y_{N-1} \leq x_0+x_1+\ldots + x_{N-1} \leq 10^9\).

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group, you need to solve all test cases in the test group.

Group | Score | Limits 1 | 16 | \(N=2, x_i \leq 100, y_i \leq 100\) 2 | 9 | \(x_i = x_j = y_i = y_j\) for all \(i,j\). In other words all the \(x\)'s and \(y\)'s in the input are the same. 3 | 19 | \(x_i, y_i \leq 1\) 4 | 24 | \(N,x_i,y_i \leq 100\) 5 | 32 | No additional constraints.

입력 형식

The first line contains one integer \(N\), the number of tiers or subscription levels.

The second line contains \(N\) integers \(x_0, x_1, \ldots, x_{N-1}\), the number of slots in the different tiers.

The third line contains \(N\) integers \(y_0, y_1, \ldots, y_{N-1}\), the number of users with each subscription level.

출력 형식

Output one integer, the maximum possible value of \(U-D\) by assigning the users to parking slots optimally.

서브태스크
서브태스크점수설명

Subtask 1

16점

None

Subtask 2

9점

None

Subtask 3

19점

None

Subtask 4

24점

None

Subtask 5

32점

None

예제 1
입력
2
3 3
1 3
출력
2
예제 2
입력
3
1 1 1
1 1 1
출력
1
예제 3
입력
6
1 0 1 1 0 1
1 1 0 0 1 0
출력
1
예제 4
입력
4
2 1 1 8
0 4 4 0
출력
-1
예제 5
입력
1
1000000000
1000000000
출력
0
문제 정보

rip 작성

출처 EGOI 2024

평가 및 의견

Bike Parking

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

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

풀이 제출

Bike Parking

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