/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 2ms 496.0 KiB
#4 Accepted 4ms 532.0 KiB
#5 Accepted 30ms 596.0 KiB
#6 Accepted 281ms 1.402 MiB
#7 Accepted 294ms 1.414 MiB
#8 Accepted 298ms 1.441 MiB
#9 Accepted 303ms 1.445 MiB
#10 Accepted 2ms 532.0 KiB

Code

 #include <iostream>

using namespace std;

int main() {
    int t, n, d, a, b;
    cin >> t; // Read the number of test cases
    for (int i = 0; i < t; i++) {
        cin >> n >> d; // Read the number of nights and the number of first nights with higher rate
        cin >> a >> b; // Read the cost per night for first D nights and subsequent nights
        // Calculate the cost for the first D nights or for all N nights if N <= D
        int firstPart = min(n, d) * a;
        // Calculate the cost for the remaining nights if N > D
        int secondPart = max(n - d, 0) * b;
        // Total cost is the sum of the above two parts
        int totalCost = firstPart + secondPart;
        cout << totalCost << endl; // Output the total cost for this test case
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1090 Summer trip
Contest
Brain Booster #5
Language
C++11 (G++ 13.2.0)
Submit At
2024-09-05 16:44:40
Judged At
2024-10-03 13:06:22
Judged By
Score
100
Total Time
303ms
Peak Memory
1.445 MiB