0pts,求调
查看原帖
0pts,求调
922644
liumuxian楼主2025/8/3 11:45
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N=1e5+10;
int a[N],ans;
bool cmp(int x,int y){
	return x>y;
}
int f(int l,int r){
	int len=0,p=r;
	while(p){
		len++;
		p/=10; 
	}
	return l*(int)pow(10,len)+r;
}
signed main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1,cmp);
	int l=1,r=n;
	while(l<=n){
		while(r>1&&f(l,r)>k) r--;
		if(f(l,r)<=k) ans+=(r-l);
		l++;
	}
	cout<<ans<<endl;
	return 0;
}
2025/8/3 11:45
加载中...