2 solutions

  • 2
    @ 2026-2-26 15:24:19
    #include<bits/stdc++.h>
    using namespace std;
    int n,k,x,y;
    int main(){
    	cin>>n>>k>>x>>y;
    	if(n<=k) cout<<n*x;
    	else cout<<k*x+(n-k)*y;
    	return 0;
    }
    

    \(^o^)/

    • -3
      @ 2025-8-7 11:51:55
      #include <bits/stdc++.h>
      using namespace std;
      const int N = 1e5 + 5;
      int n,k,x,y,ans;
      
      signed main() {
      	cin>>n>>k>>x>>y;
      	if(n<=k){
      		ans=n*x;
      	}else{
      		n-=k;
      		ans=k*x+n*y;
      	}
      	cout<<ans<<"\n";
      	return 0;
      }//4 9 10
      
      • 1

      Information

      ID
      4958
      Time
      2000ms
      Memory
      256MiB
      Difficulty
      2
      Tags
      (None)
      # Submissions
      35
      Accepted
      24
      Uploaded By