# BULLET - Editorial

Setter: Kanhaiya Mohan
Tester: Harris Leung
Editorialist: Trung Dang

Cakewalk

None

# PROBLEM:

Mario’s bullet moves at X pixels per frame. He wishes to shoot a goomba standing Y pixels away from him. The goomba does not move.

Find the minimum time (in seconds) after which Mario should shoot the bullet, such that it hits the goomba after at least Z seconds from now.

# EXPLANATION:

The bullet takes \frac{Y}{X} seconds to reach Goomba, therefore we need to wait at most \max(0, Z - \frac{Y}{Z}) seconds to fire the bullet.

# TIME COMPLEXITY:

Time complexity is O(1) for each test case.

# SOLUTION:

Setter's Solution
#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--){
int x, y, z;
cin>>x>>y>>z;
cout<<max(0, z-y/x);
cout<<endl;
}
return 0;
}

Tester's Solution
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
ll n;
ll a[2001];
ll dp[2001];
void solve(){
ll x,y,z;cin >> x >> y >> z;
ll ans=max(0LL,z-y/x);
cout << ans << '\n';
}
int main(){
ios::sync_with_stdio(false);cin.tie(0);
int t;cin >> t;while(t--) solve();
}

Editorialist's Solution
#include <bits/stdc++.h>
using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
while (t--) {
int x, y, z; cin >> x >> y >> z;
cout << max(0, z - y / x) << '\n';
}
}