/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 428.0 KiB
#2 Accepted 1ms 320.0 KiB
#3 Accepted 2ms 320.0 KiB
#4 Accepted 5ms 552.0 KiB
#5 Accepted 32ms 636.0 KiB
#6 Accepted 299ms 1.434 MiB
#7 Accepted 303ms 1.293 MiB
#8 Accepted 302ms 1.43 MiB
#9 Accepted 307ms 1.418 MiB
#10 Accepted 2ms 324.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-11-11 02:59:38
Judged By
Score
100
Total Time
307ms
Peak Memory
1.434 MiB