#include<cstdio> #include<queue> using namespace std; int n; long long r; priority_queue<int> pq; int main() { scanf("%d", &n); for (int i = 0, x; i < n; i++) { scanf("%d", &x); x -= i; if (!pq.empty() && pq.top() > x) { r += pq.top() - x; pq.pop(); pq.push(x); } pq.push(x); } printf("%lld", r); return 0; }
13323번: BOJ 수열 1
https://www.acmicpc.net/problem/13323
피드 구독하기:
댓글
(
Atom
)
댓글 없음 :
댓글 쓰기