1 solutions

  • 0
    @ 2025-04-08 09:09:17

    Author : Jahirul Islam Hridoy

    • Understanding the Distribution:

      • Hridoy gives away his tickets first from his collection of A tickets.

      • Kamona gives away her tickets only after Hridoy has exhausted his.

    A total of exactly X tickets are given away.

    • Key Observations:

      • If X ≤ A, then Hridoy alone distributes the tickets.Hridoy’s remaining tickets: A − X

      • Kamona's remaining tickets: B (since he doesn't distribute any)If X > A, then Hridoy distributes all his A tickets, and Kamona gives away the remaining (X − A) tickets.

      • Hridoy’s remaining tickets: 0

      • Kamona’s remaining tickets: B − (X − A)

    • Formulating the Answer:

      • Hridoy’s tickets left: max(A − X, 0)

      • Kamona’s tickets left: • If X ≤ A, then it remains B. • Otherwise, it is B − (X − A).

    • Example: Suppose A = 5, B = 3, and X = 7.

      • Since 7 > 5, Hridoy gives away all 5 tickets, and Kamona gives away 7 − 5 = 2 tickets.

      • Remaining tickets: • Hridoy: 0 • Kamona: 3 − 2 = 1

    Code (C++) :

    // Author : Kamonasish Roy (Bullet)
    // Time : 2025-03-27 03:53:47
    
    #include<bits/stdc++.h>
    using namespace std;
    const long long M=5e5,MOD=1e9+7;
    typedef long long ll;
    
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int t=1;
        cin>>t;
        while(t--){
        	int hridoy,kamona,x;
        	cin>>hridoy>>kamona>>x;
        	cout<<hridoy-min(x,hridoy)<<" "<<kamona-max(0,min(kamona,x-hridoy))<<"\n";
        	
        	
        	
        	}
        	
        	   
        return 0;
     
    }
    
  • 1

Information

ID
1187
Difficulty
1
Category
Math Click to Show
Tags
# Submissions
129
Accepted
53
Accepted Ratio
41%
Uploaded By