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

Čokolade

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

의견: 0

설명

Little Lana and little Fran are visiting a chocolate factory. They have seen how
chocolate is made, tasted many chocolates, and now they want to buy some of the
chocolates.
In the shop, there are \(n\) different chocolates, and the \(i-th\) of them has the price
\(c@@RISE_MATH_BLOCK_0@@i - k\)
kunas.
Let’s denote \(l\) as the amount Lana has to pay, and \(f\) as the amount Fran has to pay. Lana, dissatisfied
with Fran’s deal, wants to spite Fran and choose the chocolates so the value of the expression \(l - f\) is as
small as possible. Since Fran is hesitant and doesn’t know how many he wants to buy, Lana wants to
know the minimal value of the expression \(l - f\) for \(q\) different numbers \(k@@RISE_MATH_BLOCK_1@@i\).
Help her choose the chocolates and determine the minimum value of the expression \(l - f\) for each of the \(q\)
queries.

제약

Subtask 1 (15 points): n, \(q \le 1000\), \(c\)\(i\), k\(i \le 10^{6}\)

Subtask 2 (20 points): \(k_{1}\) = . . . = \(k_{n}\)

Subtask 3 (35 points): No additional constraints.

입력 형식

The first line contains two integers \(n\) and \(q\) (\(1 \le n\), \(q \le 10^{5}\)), the number of chocolates, and the number of
queries.
The second line contains \(n\) integers \(c\)1, c2, . . . , c\(q\) (\(1 \le c@@RISE_MATH_BLOCK_0@@i\) and \(m@@RISE_MATH_BLOCK_1@@i \le 10^{9}\), \(1 \le m\)\(i \le n\)), Fran’s bound, and the
number of chocolates they are going to buy.

출력 형식

Print \(q\) lines. In the \(i-th\) line print the answer to Lana’s \(i-th\) query.

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

1

15점

n, \(q \le 1000\), \(c\)\(i\), k\(i \le 10^{6}\)

2

20점

\(k_{1}\) = . . . = \(k_{n}\)

3

35점

No additional constraints.

예제 1
입력
5 2
1 9 22 10 19
18 4
5 2
출력
34
-21
예제 2
입력
7 4
1 5 4 3 7 11 9
5 4
5 7
7 3
4 5
출력
4
16
7
1
예제 3
입력
3 3
5 6 7
10 1
5 3
3 3
출력
5
12
0
설명

Clarification of the first example:
In the first query, Lana can take chocolates with prices 1, 9, 22, and 10. Lana will pay 38 kunas, and Fran
4 kunas. The answer is 38 −4 = 34.
In the second query, Lana will choose chocolates with prices 22 and 19. She will pay 10 kunas, and Fran
will pay 31 kunas. The answer is 10 −31 = −21.

문제 정보

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

출처 COCI 2022/2023 Contest 1

평가 및 의견

Čokolade

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

Log in to rate problems.

개별 의견

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

풀이 제출

Čokolade

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