/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 1ms 320.0 KiB
#4 Accepted 2ms 320.0 KiB
#5 Accepted 6ms 640.0 KiB
#6 Accepted 43ms 1.465 MiB
#7 Accepted 44ms 1.391 MiB
#8 Accepted 41ms 1.324 MiB
#9 Accepted 42ms 1.227 MiB
#10 Accepted 1ms 388.0 KiB

Code

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define f(i,x,y) for(int i=x;i<y;i++)
#define f2(i,x,y) for(int i=x;i>=y;i--)
#define pii pair<int,int>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int MOD =1000000007;
const int INF = 1e18;
const int N = 2e5;
 
void solve(int tc){
    int n,k; cin >> n >> k;
    int a,b; cin >> a >> b;
    cout << min(n,k)*a + max(0LL,n-k)*b << endl;
}
int32_t main(){

    Fast

    int t=1;

    cin >> t;

    for(int tc=1;tc<=t;tc++){

        solve(tc);
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1090 Summer trip
Language
C++20 (G++ 13.2.0)
Submit At
2024-10-03 14:27:38
Judged At
2024-11-11 02:51:25
Judged By
Score
100
Total Time
44ms
Peak Memory
1.465 MiB