1 solutions

  • 0
    @ 2025-12-3 17:12:23

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    long long n,t,x,a1,b1,a2,b2,ans;
    int main()
    {
    //	freopen("590.in","r",stdin);
    //	freopen("590.out","w",stdout);	
    	cin>>n>>t>>x;
    	a1=x,b1=x+t-1;
    	ans=b1-a1+1;
    	for(int i=1;i<n;i++)
    	{
    		cin>>x;
    		a2=x,b2=x+t-1;
    		if(a2>b1) ans+=t;
    		else ans+=t-(b1-a2+1);
    		a1=a2,b1=b2;
    	}
    	cout<<ans;
    	return 0;
    } 
    
    • 1

    2019NHOI小甲模拟第三题 兴奋的桐桐(1.9)

    Information

    ID
    962
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By