/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 3ms 564.0 KiB
#2 Accepted 2ms 648.0 KiB
#3 Accepted 2ms 328.0 KiB
#4 Accepted 4ms 772.0 KiB
#5 Accepted 22ms 588.0 KiB
#6 Accepted 184ms 1.305 MiB
#7 Accepted 213ms 1.387 MiB
#8 Accepted 210ms 1.461 MiB
#9 Accepted 212ms 1.457 MiB
#10 Accepted 2ms 528.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-11-11 03:00:35
Judged By
Score
100
Total Time
213ms
Peak Memory
1.461 MiB