/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 552.0 KiB
#2 Accepted 1ms 532.0 KiB
#3 Accepted 2ms 764.0 KiB
#4 Accepted 4ms 544.0 KiB
#5 Accepted 29ms 576.0 KiB
#6 Accepted 291ms 1.367 MiB
#7 Accepted 287ms 1.371 MiB
#8 Accepted 289ms 1.391 MiB
#9 Accepted 287ms 1.266 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-09-05 16:44:51
Judged By
Score
100
Total Time
291ms
Peak Memory
1.391 MiB