1 条题解

  • 0
    @ 2026-9-1 15:48:07
    #include<iostream>
    using namespace std;
    int n;
    long long l,w,a[100003],x,ans;
    int main(){
    	cin.tie(0)->sync_with_stdio(false);
    	cout.tie(0);
    	cin>>n>>l>>w;
    	for(int i=1;i<=n;i++)cin>>a[i];
    	for(int i=1;i<=n;i++){
    		if(x<a[i])ans+=(a[i]-x+w-1ll)/w;
    		x=a[i]+w;
    	}
    	if(x<l)cout<<ans+(l-x+w-1ll)/w;
    	else cout<<ans;
    	return 0;
    }
    
    • 1

    信息

    ID
    2491
    时间
    2000ms
    内存
    1024MiB
    难度
    10
    标签
    递交数
    6
    已通过
    3
    上传者