1 solutions

  • 0
    @ 2025-4-18 18:42:56
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int x,y,z;
    	cin>>x>>y>>z;
    	if(y<0) 
    	{
    		x=-x;
    		y=-y;
    		z=-z;
    	}
    	if(x<y)
    	{
    		cout<<abs(x);
    	}
    	else
    	{
    		if(z>y)
    		{
    			cout<<-1;
    		}
    		else
    		{
    			cout<<abs(z)+abs(x-z); 
    		}
    	}
    	return 0;
    }
    
    
    • 1

    Information

    ID
    2365
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    3
    Tags
    (None)
    # Submissions
    36
    Accepted
    12
    Uploaded By