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

Minimum Sum of Maximums

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

의견: 0

설명

Bessie has \(N\) (\(2\le N\le 300\)) tiles in a line with ugliness values
\(a_1, a_2, \dots, a_N\) in that order (\(1\le a_i\le 10^6\)). \(K\)
(\(0\le K\le \min(N,6)\)) of the tiles are stuck in place; specifically, those at
indices \(x_1,\dots, x_K\) (\(1\le x_1 < x_2<\dots< x_K\le N\)).

Bessie wants to minimize the total ugliness of the tiles, which is defined as
the sum of the maximum ugliness over every consecutive pair of tiles; that is,
\(\sum_{i=1}^{N-1}\max(a_i,a_{i+1})\). She is allowed to perform the following
operation any number of times: choose two tiles, neither of which are stuck in
place, and swap them.

Determine the minimum possible total ugliness Bessie can achieve if she performs
operations optimally.

Problem credits: Benjamin Qi

제약

SCORING

  • Input 5: \(K=0\)
  • Inputs 6-7: \(K=1\)
  • Inputs 8-12: \(N\le 50\)
  • Inputs 13-24: No additional constraints

Problem credits: Benjamin Qi

입력 형식

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

The next line contains \(a_1,\dots,a_N\).

The next line contains the \(K\) indices \(x_1,\dots,x_K\).

출력 형식

Output the minimum possible total ugliness.

예제 1
입력
3 0
1 100 10
출력
110
설명

Bessie can swap the second and third tiles so that \(a=[1,10,100]\), achieving
total ugliness \(\max(1,10)+\max(10,100)=110\). Alternatively, she could swap the
first and second tiles so that \(a=[100,1,10]\), also achieving total ugliness
\(\max(100,1)+\max(1,10)=110\).

예제 2
입력
3 1
1 100 10
3
출력
110
설명

Bessie could swap the first and second tiles so that \(a=[100,1,10]\), achieving
total ugliness \(\max(100,1)+\max(1,10)=110\).

예제 3
입력
3 1
1 100 10
2
출력
200
설명

The initial total ugliness of the tiles is \(\max(1,100)+\max(100,10)=200\).
Bessie is only allowed to swap the first and third tiles, which does not allow
her to reduce the total ugliness.

예제 4
입력
4 2
1 3 2 4
2 3
출력
9
문제 정보

riseoj 작성

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

태그

평가 및 의견

Minimum Sum of Maximums

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

Log in to rate problems.

개별 의견

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

풀이 제출

Minimum Sum of Maximums

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