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

S2. Tandem Bicycle

Unrated 레이팅 미적용
난이도
2s
시간 제한
256MB
메모리 제한
0
맞았습니다!!
0
제출 수
0.0%
정답률
레이팅

의견: 0

설명

Since time immemorial, the citizens of Dmojistan and Pegland have
been at war. Now, they have finally signed a truce. They have decided to
participate in a tandem bicycle ride to celebrate the truce. There are
\(N\) citizens from each country. They
must be assigned to pairs so that each pair contains one person from
Dmojistan and one person from Pegland.

Each citizen has a cycling speed. In a pair, the fastest person will
always operate the tandem bicycle while the slower person simply enjoys
the ride. In other words, if the members of a pair have speeds \(a\) and \(b\), then the bike
speed
of the pair is \(\max(a,b)\). The total
speed
is the sum of the \(N\) individual bike
speeds
.

For this problem, in each test case, you will be asked to answer one
of two questions:

  • Question 1: what is the minimum total speed, out of
    all possible assignments into pairs?

  • Question 2: what is the maximum total speed, out of
    all possible assignments into pairs?

제약

\((1 \leq N \leq 100)\)

입력 형식

The first line will contain the type of question you are to solve,
which is either \(1\) or \(2\).

The second line contains \(N\)
\((1 \leq N \leq 100)\).

The third line contains \(N\)
space-separated integers: the speeds of the citizens of Dmojistan.

The fourth line contains \(N\)
space-separated integers: the speeds of the citizens of Pegland.

Each person’s speed will be an integer between \(1\) and \(1\ 000\ 000\).

For 8 of the 15 available marks, questions of type \(1\) will be asked. For 7 of the 15
available marks, questions of type \(2\) will be asked.

출력 형식

Output the maximum or minimum total speed that answers the question
asked.

예제 1
입력
1
3
5 1 4
6 2 4
출력
12
설명

There is a unique optimal solution:

  • Pair the citizen from Dmojistan with speed 5 and the citizen from
    Pegland with speed 6.

  • Pair the citizen from Dmojistan with speed 1 and the citizen from
    Pegland with speed 2.

  • Pair the citizen from Dmojistan with speed 4 and the citizen from
    Pegland with speed 4.

예제 2
입력
2
3
5 1 4
6 2 4
출력
15
설명

There are multiple possible optimal solutions. Here is one optimal
solution:

  • Pair the citizen from Dmojistan with speed 5 and the citizen from
    Pegland with speed 2.

  • Pair the citizen from Dmojistan with speed 1 and the citizen from
    Pegland with speed 6.

  • Pair the citizen from Dmojistan with speed 4 and the citizen from
    Pegland with speed 4.

예제 3
입력
2
5
202 177 189 589 102
17 78 1 496 540
출력
2016
설명

There are multiple possible optimal solutions. Here is one optimal
solution:

  • Pair the citizen from Dmojistan with speed 202 and the citizen
    from Pegland with speed 1.

  • Pair the citizen from Dmojistan with speed 177 and the citizen
    from Pegland with speed 540.

  • Pair the citizen from Dmojistan with speed 189 and the citizen
    from Pegland with speed 17.

  • Pair the citizen from Dmojistan with speed 589 and the citizen
    from Pegland with speed 78.

  • Pair the citizen from Dmojistan with speed 102 and the citizen
    from Pegland with speed 496.

This sum yields \(202+540+189+589+496=2016\).

문제 정보

생성자가 기록되지 않았습니다.

출처 CCC 2016 Senior

평가 및 의견

S2. Tandem Bicycle

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

Log in to rate problems.

개별 의견

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

풀이 제출

S2. Tandem Bicycle

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