186B - Growing Mushrooms - CodeForces Solution


greedy sortings *1200

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
// #include <boost/algorithm/string.hpp>
 
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(a) (ll)a.size()
#define py cout<<"YES\n";
#define pn cout<<"NO\n";
const int MOD = 1000000007;
#define forn(i, n) for (int i = 0; i < int(n); i++)


const double PI = acos(-1);
// #define size 102

const int MXX = 1001;
bitset<MXX + 1> isPrime;
vector<int> primes;

// long matrix[size][size];

// int a[size][size],b[size][size];
void sieve() {
    // false = prime, true = not prime
    isPrime[0] = isPrime[1] = true;
    for (int i = 4; i <= MXX; i += 2) isPrime[i] = true;
 
    for (int i = 3; 1LL * i * i <= MXX; i += 2) {
        if (!isPrime[i]) {
            for (int64_t j = i * i; j <= MXX; j += i + i) isPrime[j] = true;
        }
    }
    for (int i = 0; i < MXX; ++i) {
        if (!isPrime[i])
            primes.push_back(i);
    }
}
struct comp{
    bool operator()(pair<int,int>&a,pair<int,int>&b){
        return a.first+a.second<b.first+b.second;
    }
};
    
bool cmp(pair<string,ll>&a, pair<string,ll>&b){
    if(a.first.size()==b.first.size())
        return a<b;
    return a.first.size()>b.first.size();
}

ll smallestPrime(ll n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
            return i;
    }
    return n;
}

bool isPal(int n){
    
    int x=0,i=n;
    while(n){
        x=(x*10+n%10);
        n/=10;
    }
    
    if(x!=i)    return false;
    return true;
}


ll rec(ll i, ll sum, vector<ll>&pal, vector<vector<ll>>&dp){
    
    if(sum==0)  return 1;
    
    if(i<0 || sum<0)    return 0;
    
    if(i==0 && sum==pal[i])     return 1;
    
    if(dp[i][sum]!=-1)  return dp[i][sum];
    
    ll take=0,leave=0;
    take =rec(i,sum-pal[i],pal,dp);
    leave=rec(i-1,sum,pal,dp);
  
    return dp[i][sum]=(take%MOD+leave%MOD)%MOD;
}
vector<ll>mirror={0,1,5,-1,-1,2,-1,-1,8,-1};

ll fact(ll n){
    if (n == 0 || n == 1)
        return 1;
    return n * fact(n - 1);
}

ll cnt(vector<ll>v){
    ll ans=0,zero=0,n=v.size();
    
    for(ll i=n-1;i>=0;i--){
        if(v[i]==0)
            zero++;
        else    ans+=zero;
        // cout<<zero<<endl;
    }
    // cout<<ans<<"fgh"<<endl;
    return ans;
}

void solve(){
    
    // ll n;    cin>>n;
   
    // string s;    cin>>s;
    // char ch;    cin>>ch;
    
    // vector<ll>v(n);
    // forn(i,n)    cin>>v[i];
    
    ll n,t1,t2,k;   cin>>n>>t1>>t2>>k;
    vector<pair<double,ll>>vp;
  
    forn(i,n){
        ll a,b; cin>>a>>b;
        
        double val=0;
        
        val=max((double)a*t1*(100-k)/100+b*t2,(double)b*t1*(100-k)/100+a*t2);
        val*=-1;
        
        vp.pb({val,i+1});
    }
  
    sort(vp.begin(),vp.end());
    
    for(auto [x,y]:vp)
        cout<<y<<" "<<-1*x<<endl;
   
   
    // cout<<"-------------"<<endl;
    
    return;
} 

int main()
{
    // clock_t time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(2);
    ll t=1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    
    // time_req = clock() - time_req;
    // cout << (float)time_req / CLOCKS_PER_SEC;
    return 0;
}


Comments

Submit
0 Comments
More Questions

Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup