| 记录编号 | 
        595699 | 
        评测结果 | 
        AAAAAAAAAAAAAAAAAAAA | 
    
    
        | 题目名称 | 
        4029.HS的数 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         小金 | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        0.709 s  | 
    
    
        | 提交时间 | 
        2024-10-15 21:18:41 | 
        内存使用 | 
        5.01 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include<iostream>
#include<cstdio>
#include<queue>
using namespace std;
int n;
long long a[200010],ans;
priority_queue<long long> q;
int main()
{
    freopen("HSshu.in","r",stdin);
	freopen("HSshu.out","w",stdout);
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
        a[i]-=i;
        q.push(a[i]);
        if(!q.empty()&&q.top()>a[i])
        {
            ans+=q.top()-a[i];
            q.pop();
            q.push(a[i]);
        }
    }
    printf("%lld",ans);
    return 0;
}