/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 532.0 KiB
#2 Accepted 2ms 532.0 KiB
#3 Accepted 2ms 532.0 KiB
#4 Accepted 7ms 320.0 KiB
#5 Accepted 35ms 604.0 KiB
#6 Accepted 285ms 1.375 MiB
#7 Accepted 272ms 1.27 MiB
#8 Accepted 272ms 1.426 MiB
#9 Accepted 273ms 1.27 MiB
#10 Accepted 2ms 532.0 KiB

Code

#include <iostream>
using namespace std;

int main() {
    int T;
    cin >> T;

    while (T--) {
        int N, D;
        cin >> N >> D;
        int A, B;
        cin >> A >> B;

        long long total_cost;
        if (N <= D) {
            total_cost = 1LL * N * A;
        } else {
            total_cost = 1LL * D * A + 1LL * (N - D) * B;
        }

        cout << total_cost << "\n";
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1090 A. Summer trip
Language
C++17 (G++ 13.2.0)
Submit At
2025-07-28 18:16:18
Judged At
2025-07-28 18:16:18
Judged By
Score
100
Total Time
285ms
Peak Memory
1.426 MiB