ENRYFEES - Editorial

PROBLEM LINK:

Practice

Contest

Author: Sibasish Ghosh

Tester: Pritish Nayak

Editorialist: Sibasish Ghosh

DIFFICULTY:

Cakewalk

PREREQUISITES:

Basic Maths

PROBLEM:

Bob is organizing a programming event. The entry fees for the event is Rs. X per participant. The prize pool is Rs. Y. What is the minimum number of participants Bob needs so that he earns a profit of at least Rs. P.

EXPLANATION:

The minimum funding Bob needs is Y+P. So, the number minimum of participants required is \lceil \frac{Y+P}{X} \rceil.

Refer to the solutions below if you face any problem.

SOLUTIONS:

Setter's/Editorialist's Solution
#include<bits/stdc++.h>
#define mod 1000000007
#define F first
#define S second
#define pb push_back
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()

using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input3.txt","r",stdin);
    // freopen("output3.txt","w",stdout);
    ll t=1;
    cin>>t;
    while(t--)
    {
        ll x,y,p,ans;
        cin>>x>>y>>p;
        ans=ceil(1.0*(y+p)/x);
        cout<<ans<<"\n";
    }
    return 0;
}
Tester's Solution
#include<bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);
   #ifdef Zoro
   freopen("/home/pritish/Competitive/in", "r", stdin);
   freopen("/home/pritish/Competitive/out", "w", stdout);
   #endif  
 
   int t;
   cin>>t;
 
   assert(t>=1&&t<=100000);
 
   while(t--)
   {
      int x,y,p;
      cin>>x>>y>>p;
 
      assert(x>=1&&x<=1000000000);
      assert(y>=1&&y<=1000000000);
      assert(p>=1&&p<=1000000000);
      
      //n>=p+y/x
      cout<<long(ceil(1.00*(p+y)/x))<<'\n';
   }
 
   cerr<<"\n"<<(float)clock()/CLOCKS_PER_SEC*1000<<" ms"<<endl;
   return 0;
} 

Feel free to write your approach in the comments :slight_smile:

3 Likes