/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Accepted 1ms 348.0 KiB
#3 Accepted 2ms 324.0 KiB
#4 Accepted 4ms 764.0 KiB
#5 Accepted 32ms 632.0 KiB
#6 Accepted 301ms 1.414 MiB
#7 Accepted 302ms 1.375 MiB
#8 Accepted 304ms 1.41 MiB
#9 Accepted 302ms 1.281 MiB
#10 Accepted 2ms 316.0 KiB

Code

#include <iostream>
using namespace std;

// Function to calculate the total accommodation fee for each test case
int calculate_fee(int N, int D, int A, int B) {
    if (N <= D) {
        return N * A;
    } else {
        return D * A + (N - D) * B;
    }
}

int main() {
    int T;
    
    // Input the number of test cases
    cin >> T;
    
    // Process each test case
    for (int i = 0; i < T; i++) {
        int N, D, A, B;
        
        // Input N (total nights) and D (discount nights)
        cin >> N >> D;
        
        // Input A (higher rate) and B (lower rate)
        cin >> A >> B;
        
        // Output the total accommodation fee for this test case
        cout << calculate_fee(N, D, A, B) << endl;
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1090 Summer trip
Language
C++11 (G++ 13.2.0)
Submit At
2024-09-07 07:00:30
Judged At
2024-11-11 02:55:40
Judged By
Score
100
Total Time
304ms
Peak Memory
1.414 MiB