/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 324.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 2ms 324.0 KiB
#4 Accepted 4ms 328.0 KiB
#5 Accepted 22ms 600.0 KiB
#6 Accepted 212ms 1.309 MiB
#7 Accepted 211ms 1.336 MiB
#8 Accepted 207ms 1.438 MiB
#9 Accepted 211ms 1.379 MiB
#10 Accepted 1ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define int long long int

void solve() {
    int n, d; 
    cin >> n >> d;
    int a, b; 
    cin >> a >> b;

    // Check if nights spent is less than or equal to the first D nights
    if (n <= d) {
        cout << n * a << endl;  // All nights are charged at the rate 'a'
    } else {
        cout << (d * a) + (n - d) * b << endl;  // First D nights at 'a', rest at 'b'
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int test;
    cin >> test;
    for (int tc = 0; tc < test; ++tc) {
        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:28:01
Judged At
2024-10-03 13:07:29
Judged By
Score
100
Total Time
212ms
Peak Memory
1.438 MiB