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

Minimum Cost Paths

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

의견: 0

설명

Farmer John's pasture can be regarded as an \(N\times M\) (\(2\le N\le 10^9\),
\(2\le M\le 2\cdot 10^5\)) 2D grid of square "cells" (picture a huge chessboard).
The cell at the \(x\)-th row from the top and \(y\)-th column from the right is
denoted by \((x,y)\) for each \(x\in [1,N], y\in [1,M]\). Furthermore, for each
\(y\in [1,M]\), the \(y\)-th column is associated with the cost \(c_y\)
(\(1\le c_y\le 10^9\)).

Bessie starts at the cell \((1,1)\). If she is currently located at the cell
\((x,y)\), then she may perform one of the following actions:

  • If \(y, Bessie may move to the next column (increasing \(y\) by one) for a cost of \(x^2\).
  • If \(x, Bessie may move to the next row (increasing \(x\) by one) for a cost of \(c_y\).

Given \(Q\) (\(1\le Q\le 2\cdot 10^5\)) independent queries each of the form
\((x_i,y_i)\) (\(x_i\in [1,N], y_i\in [1,M]\)), compute the minimum possible total
cost for Bessie to move from \((1,1)\) to \((x_i,y_i)\).

Problem credits: Benjamin Qi

제약

SCORING

  • Test cases 1-3 satisfy \(N,M\le 2000\).
  • Test cases 4-8 satisfy \(c_2>c_3>\cdots>c_M\).
  • Test cases 9-15 satisfy \(N\le 2\cdot 10^5\).
  • Test cases 16-20 satisfy no additional constraints.

Problem credits: Benjamin Qi

입력 형식

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

The second line contains \(M\) space-separated integers \(c_1,c_2,\ldots,c_M\).

The third line contains \(Q\).

The last \(Q\) lines each contain two space-separated integers \(x_i\) and \(y_i\).

출력 형식

\(Q\) lines, containing the answers for each query.

Note that the large size of integers involved in this problem may require the
use of 64-bit integer data types (e.g., a "long long" in C/C++).

예제 1
입력
5 4
1 100 100 20
20
1 1
2 1
3 1
4 1
5 1
1 2
2 2
3 2
4 2
5 2
1 3
2 3
3 3
4 3
5 3
1 4
2 4
3 4
4 4
5 4
출력
0
1
2
3
4
1
5
11
19
29
2
9
20
35
54
3
13
29
49
69
설명

The output in grid format:

    1  2  3  4
  *--*--*--*--*
1 | 0| 1| 2| 3|
  *--*--*--*--*
2 | 1| 5| 9|13|
  *--*--*--*--*
3 | 2|11|20|29|
  *--*--*--*--*
4 | 3|19|35|49|
  *--*--*--*--*
5 | 4|29|54|69|
  *--*--*--*--*
문제 정보

riseoj 작성

출처 올림피아드 > USACO > 2020-2021 > January > Platinum

태그

평가 및 의견

Minimum Cost Paths

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

Log in to rate problems.

개별 의견

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

풀이 제출

Minimum Cost Paths

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