903B - The Modcrab - CodeForces Solution


greedy implementation *1200

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
using ll =long long;
//const ll N=1e7+1;
#define pb push_back



// TEMPLATES
 
 template <typename T> // cin >> vector<T>
istream &operator>>(istream &istream, vector<T> &v)
{
    for (auto &it : v)
        cin >> it;
    return istream;
}
 
template <typename T> // cout << vector<T>
ostream &operator<<(ostream &ostream, const vector<T> &c)
{
   for (auto &it : c)
      cout << it << " ";
   return ostream;
}



long long binconvert(int n) 
{
  long long bin = 0;
  int rem, i = 1;
 
 
  while (n!=0) {
    rem = n % 2;
    n /= 2;
    bin += rem * i;
   
    i *= 10;
  }
 
 
  return bin;
}

bool isprime(ll n)
{
    int cnt=0;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            cnt++;
            if(i!=n/i)
            {
                cnt++;
            }
 
        }
        
    }
    if(cnt>2)
    {
        return 0;
    }
    return 1;
}
ll fact(ll n)
{
      if(n==0)
      return 1;
    ll res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}
 
ll ncr(ll n, ll r)
{
    return fact(n) / (fact(r) * fact(n - r));
}
vector<ll>m(102,0);
void solve2(ll d,vector<ll>v,ll s,ll e)
{
     if(s>=e)
     {
        return;
     }
   ll mx=INT_MIN;
   ll ind=0;
    for(int i=s;i<e;i++)
    {
        if(v[i]>mx)
        {
            mx=v[i];
            ind=i;

        }
    }
    m[v[ind]]=d;
    d++;
    solve2(d,v,s,ind);
    solve2(d,v,ind+1,e);

}
//vector<int>prime(N+2,1);
// void sieve_erastosthenes()
// {
//      for(int i=2;i*i<=N+1;i++)
//      {
//         if(prime[i]==1)
//         {
//             for(int j=i*i;j<=N+1;j+=i)
//             {
//                 prime[j]=false;
//             }
//         }
//      }


// }
void solve()
{
    int a1,a2,h1,h2,c1;
    cin>>h1>>a1>>c1;
    cin>>h2>>a2;
    int count=0;
    while(ceil(h1*1.0/a2)<ceil(1.0*h2/a1))
    {
      
        count++;
        h1+=c1-a2;
    }
    int z=ceil(h2*1.0/a1*1.0);
    cout<<count+z<<"\n";
    while(count--)
    {
          cout<<"HEAL"<<"\n";
    }
    while(z--)
    {
        cout<<"STRIKE"<<"\n";

    }

    
}
int main()
{
    ll t;
    t=1;
  // cin>>t;
  // sieve_erastosthenes();
    while(t--)
    {
        solve();
    }
}


Comments

Submit
0 Comments
More Questions

1515E - Phoenix and Computers
1552B - Running for Gold
994A - Fingerprints
1221C - Perfect Team
1709C - Recover an RBS
378A - Playing with Dice
248B - Chilly Willy
1709B - Also Try Minecraft
1418A - Buying Torches
131C - The World is a Theatre
1696A - NIT orz
1178D - Prime Graph
1711D - Rain
534A - Exam
1472A - Cards for Friends
315A - Sereja and Bottles
1697C - awoo's Favorite Problem
165A - Supercentral Point
1493A - Anti-knapsack
1493B - Planet Lapituletti
747B - Mammoth's Genome Decoding
1591C - Minimize Distance
1182B - Plus from Picture
1674B - Dictionary
1426C - Increase and Copy
520C - DNA Alignment
767A - Snacktower
1365A - Matrix Game
714B - Filya and Homework
31A - Worms Evolution