/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 2ms 700.0 KiB
#3 Accepted 2ms 704.0 KiB
#4 Accepted 2ms 548.0 KiB
#5 Accepted 5ms 540.0 KiB
#6 Accepted 39ms 1.316 MiB
#7 Accepted 41ms 1.367 MiB
#8 Accepted 39ms 1.27 MiB
#9 Accepted 41ms 1.27 MiB
#10 Accepted 2ms 452.0 KiB

Code

#include <bits/stdc++.h>
 
using namespace std;
 
// Macros
#define REP(i, j, n) for(int i = j; i < n; i++)
#define trav(i, a) for(auto i: a)
#define all(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define F first
#define S second
#define GCD __gcd
 
// Type Names
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int, int> pii;

// Global Variables
const int MOD = 1e9 + 7;

// custom hash
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

// print vector X)
template <typename T>
void print_vector(vector<T> a){
    int n = a.size();
    for (int i = 0; i < n; i++){
        cout << a[i] << (i == n - 1 ? "\n" : " ");
    }
}

template <typename T>
void print_2d_vector(vector<vector<T>> a){
    int row = a.size();
    int col = a[0].size();
    for (int i = 0; i < row; i++){
        for (int j = 0; j < col; j++){
            cout << a[i][j] << " ";
        }
        cout << "\n";
    }
}

template <typename T>
void print_stack(stack<T> st){
    while (!st.empty()){
        cout << st.top() << " ";
        st.pop();
    }
    cout << "\n";
}

template <typename T>
void print_set(set<T> s){
    for (auto itr = s.begin(); itr != s.end(); itr++){
        cout << *itr << " ";
    }
    cout << "\n";
}

template <typename T>
void print_set(multiset<T> s){
    for (auto itr = s.begin(); itr != s.end(); itr++){
        cout << *itr << " ";
    }
    cout << "\n";
}

string int_to_bin(ll n){
    string ans = "";
    while (n) {
        ans = to_string(n % 2) + ans;
        n /= 2;
    }
    return ans;
}

ull bin_to_int(string s){
    bitset<20> bin(s);
    return bin.to_ulong();
}

ll find_next(ll l, ll n){
    if ((l - 1) % n == 0) return l - 1;
    else return (((l - 1) / n) * n) + n;
}

ll find_prev(ll r, ll n){
    return (r / n) * n;
}

void solve()
{   
    ll n, d, a, b;
    cin >> n >> d;
    cin >> a >> b;
    ll ans = 0;
    if (n <= d){
        ans += n * a;
    }
    else {
        ans += d * a;
        ans += (n - d) * b;
    }
    cout << ans << "\n";
}

 
int main()
{
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("breedflip.in", "r", stdin);
    // freopen("breedflip.out", "w", stdout);
    int t;
    cin >> t;
    for(int i = 1; i <= t; i++)
    solve();
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1090 Summer trip
Contest
Brain Booster #5
Language
C++17 (G++ 13.2.0)
Submit At
2024-09-05 16:14:16
Judged At
2024-09-05 16:14:16
Judged By
Score
100
Total Time
41ms
Peak Memory
1.367 MiB