forked from Prince-1501/Hello_world-Competiitve-Programming
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Chef and Price Control.cpp
43 lines (39 loc) · 1.03 KB
/
Chef and Price Control.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//
// COMPETITIVE PROGRAMMING .cpp
//
// Created by Prince Kumar on 15/06/2020.
// Copyright © 2020 Prince Kumar. All rights reserved.
//
// ---** COMPETITIVE PROGRAMMING in C++ **---
// ---** PRACTICE CODING SKILLS **---
#include <iostream>
using namespace std;
int main(){
int T; cin>>T;
while(T--){
int n, k; cin>>n>>k;
int prev_amt=0;
int ori_amt=0;
// 2 3 4 7 10 5
for(int i=0;i<n;i++){
int x; cin>>x; // x = 2
prev_amt+=x; // profit initially prev_Amt = 2
if(x>k){
x=k;
} // x= 5
ori_amt+=x; // ori_amt = 2
}
cout<<prev_amt-ori_amt<<endl;
// int a[n];
// for(int i=0;i<n;i++){
// cin>>a[i];
// prev_amt+=a[i];
// }
// for(int i=0;i<n;i++){
// if(a[i]>k){
// a[i]=k;
// }
// ori_amt+=a[i];
// }
}
}