/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 556.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 2ms 448.0 KiB
#4 Accepted 1ms 540.0 KiB
#5 Accepted 5ms 640.0 KiB
#6 Accepted 38ms 1.398 MiB
#7 Accepted 38ms 1.27 MiB
#8 Accepted 38ms 1.27 MiB
#9 Accepted 39ms 1.324 MiB
#10 Accepted 2ms 448.0 KiB

Code

#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;

typedef long long int ll ;
//typedef __int128 lll;
#define pb push_back
#define pinf   2e18
#define ninf   -2e18
#define PI    acos(-1.0)
#define endl  "\n"
#define F first
#define S second

//template <typename T> using o_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll gcd (ll a,ll b) {
    if(a%b==0)return b;
    return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //inout() ;

    ll t,i,j ;
    cin>>t ;
    while(t--) {
        ll a,b,n,d;
        cin>>n>>d;
        cin>>b>>a;
        ll ans=min(n,d)*b;
        ans+=max(n-min(n,d),0LL)*a;
        
        cout<<ans<<'\n';





    }
    return 0 ;
}

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:48:47
Judged At
2024-09-05 15:48:47
Judged By
Score
100
Total Time
39ms
Peak Memory
1.398 MiB