0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 13:58:48 +00:00

C - Sonya and Problem Wihtout a Legend

https://codeforces.com/contest/713/submission/188408984
This commit is contained in:
Baoshuo Ren 2023-01-08 18:28:05 +08:00
parent 1bbe5af4cb
commit fb4c5d18ef
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

35
Codeforces/713/C/C.cpp Normal file
View File

@ -0,0 +1,35 @@
#include <iostream>
#include <queue>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 1e6 + 5;
int n;
long long ans;
std::priority_queue<long long> q;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1, x; i <= n; i++) {
cin >> x;
q.emplace(x - i);
if (q.top() > x - i) {
ans += q.top() - (x - i);
q.pop();
q.emplace(x - i);
}
}
cout << ans << endl;
return 0;
}