/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 556.0 KiB
#4 Accepted 2ms 492.0 KiB
#5 Accepted 5ms 540.0 KiB
#6 Accepted 39ms 1.352 MiB
#7 Accepted 38ms 1.27 MiB
#8 Accepted 38ms 1.406 MiB
#9 Accepted 39ms 1.387 MiB
#10 Accepted 1ms 540.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define Raihan ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*
vector<ll>v={1,2,3};
    do{

    }while(next_permutation(all(v)));
*/
/*

const int N=1e6+5;
bool f[N];
vector<int>prim;
for(int i=2;i*i<N;i++){
    if(!f[i]){
        for(int j=i*i;j<N;j=j+i){
            f[j]=true;
        }
    }
}
for(int i=2;i<N;i++){
    if(!f[i])prim.pb(i);
}*/

/*round(pow(5, 2))*/
/*
ll l=1,r=n;
    while(l<=r){
        ll mi=(l+r)/(ll)2;//upper bound
        if(a[mi]>dor)r=mi-1;
        else l=mi+1;
    }
*/
/*
memset(a,-1,sizeof a);
it works for 0,-1 and character,and faster than looping*/
/*
int ps=s[i]-'a'+1;
int ps=s[i]-'0'+1;
int ps=s[i]-'A'+1;
char ch='a'-1+i;
char ch='A'-1+i;
*/
/*set<int>st;
   st.insert(3);
   st.insert(4);
   for(auto it=st.begin(); it!=st.end(); it++)cout<<*it<<spc;
   cout<<endl;
   auto fi=st.begin();
   //s1.erase(fi);
   cout<<*fi<<endl;
   auto las=st.end();
   las--;
   cout<<*las<<endl;
   auto it=st.lower_bound(4);
   cout<<*it<<endl;
   it=st.upper_bound(4);
   cout<<*it<<endl;
   */
/*
for(auto it=st.begin(); it!=st.end(); it++)cout<<*it<<spc;
*/
/*
biyog korle ei doroner mod korbe.mod er problem e.
ll ans=fi-sc;
if(ans<0){
ans=ans+mod;
}
ll fact[N];
void ft()
{
	fact[0] = 1;
	for(ll i=1;i<N;i++)
	{
		fact[i] = i * fact[i - 1];
		fact[i] %= mod;
	}
}
ll pwr(long long p, long long q, const ll mod1)
{
	ll ans = (ll)1 % mod1;
	p %= mod1;
	if (p < 0)
		p += mod1;
	while (q)
	{
		if (q & (ll)1)
			ans = ((ans%mod1)*(p%mod1)) % mod1;
		p = ((p%mod1)*(p%mod1)) % mod1;
		q >>= (ll)1;
	}
	return ans;
}

ll ncr(ll n, ll r)
{
	if (n < r)
		return (ll)0;
	ll ans = (ll)1;
	ans *= fact[n];
	ll div = fact[r];
	div *= fact[n - r];
	div %= mod;
	ans *= pwr(div, mod - (ll)2, mod);
	ans %= mod;
	return ans;
}
    ll ck(ll ans){
    if(ans<0)ans=ans+mod;
        return ans%mod;
    }
*/
/*
vector<int>v({1,1,1,2,3,4,4});
    ll z=lower_bound(all(v),4)-v.begin();
    ll z1=upper_bound(all(v),4)-v.begin();
    cout<<z<<spc<<z1;
*/
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mod 1000000007
#define vec vector<int>
#define print1(pr) for(int i=0;i<pr.size();i++)cout<<pr[i]<<spc;cout<<endl;
#define print2(pr) for(int i=pr.size()-1;i>=0;i--)cout<<pr[i];cout<<endl;
#define pb push_back
#define test int tes ;cin>>tes;while(tes--)
#define pi 2*acos(0.0)
#define all(v) v.begin(),v.end()
#define no cout<<"NO"<<endl
#define yes cout<<"YES"<<endl
#define pii pair<int,int>
#define pII pair<ll,ll>
#define endl '\n'
#define spc " "
#define vl it->first
#define fq it->second
/*
int t;cin>>t;loop(i,1,t) cout<<"Case "<<i<<": ",solution();
*/
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define kajj for(auto it=mp.begin();it!=mp.end();it++)
#define input ll n;cin>>n;ll a[n+1];for(int i=1;i<=n;i++)cin>>a[i];
#define lc (nd<<1)
#define rc ((nd<<1)+1)
void solution()
{
    ll n,d,a,b;
    cin>>n>>d;
    cin>>a>>b;
    ll ans=0;
    if(n>=d){
       ans=d*a+(n-d)*b;
    }
    else{
        ans=n*a;
    }
    cout<<ans<<endl;
}
int main()
{
    Raihan;
    test
    solution();
}

Information

Submit By
Type
Submission
Problem
P1090 Summer trip
Contest
Brain Booster #5
Language
C++20 (G++ 13.2.0)
Submit At
2024-09-05 15:49:24
Judged At
2024-09-05 15:49:24
Judged By
Score
100
Total Time
39ms
Peak Memory
1.406 MiB