/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 2ms 760.0 KiB
#3 Accepted 2ms 652.0 KiB
#4 Accepted 3ms 780.0 KiB
#5 Accepted 12ms 540.0 KiB
#6 Accepted 116ms 1.27 MiB
#7 Accepted 115ms 1.418 MiB
#8 Accepted 116ms 1.383 MiB
#9 Accepted 127ms 1.453 MiB
#10 Accepted 2ms 540.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-09-05 16:28:01
Judged By
Score
100
Total Time
127ms
Peak Memory
1.453 MiB