ccfcsp-202112-1、序列查询
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, N;
cin >> n >> N;
vector<int> A(n + 1,0);
vector<int> fa(N + 1,0);
for(int i = 1; i <= n; i++){
cin >> A[i];
}
int j = 1;
int sum = 0;
for(int i = 1; i <= N; i++){
fa[i] = fa[i - 1];
if(j < A.size() && i >= A[j]){
fa[i]++;
j++;
}
if(i == N)
break;
sum += fa[i];
}
cout << sum;
return 0;
}
原文地址:https://blog.csdn.net/weixin_51503393/article/details/142137026
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!