比赛 NOIP2023模拟赛5 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 Ntarsis Set 最终得分 100
用户昵称 op_组撒头屯 运行时间 0.057 s
代码语言 C++ 内存使用 2.60 MiB
提交时间 2023-11-17 09:02:39
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
const int N=200000+5;
int n,k;
int a[N]; 
int main(){
	freopen ("ntarsis_set.in","r",stdin);
	freopen ("ntarsis_set.out","w",stdout);
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++)scanf("%d",&a[i]);
	ll cur=1;
	for (int i=1,j=1;i<=k;i++){
	    while(j<=n&&a[j]-j<cur)j++;
	    cur+=j-1;
    }
    printf("%lld\n",cur);
	return 0;
}