Accepted
Code
#include<bits/stdc++.h>
using namespace std;
#define ll long long
void solve(){
ll n,d,a,b;
cin>>n>>d>>a>>b;
if(n<=d){
cout<<a*n<<endl;
}
else{
ll x=n-d;
ll cost=x*b+d*a;
cout<<cost<<endl;
}
}
int main()
{
int n;
cin>>n;
while(n--){
solve();
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1090 Summer trip
- Contest
- Sylhet ICPC 2024 Collaborative Challenge: Episode 2
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-10-30 08:49:50
- Judged At
- 2024-10-30 08:49:50
- Judged By
- Score
- 100
- Total Time
- 213ms
- Peak Memory
- 1.34 MiB