From 5efcaba304e98e6f6e5cd25484f76c5c374e6575 Mon Sep 17 00:00:00 2001 From: Saharsh0602 Date: Thu, 1 Oct 2020 04:46:00 +0530 Subject: [PATCH] Added PRICECON in Codechef --- CodeChef/FEB15/PRICECON.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 CodeChef/FEB15/PRICECON.cpp diff --git a/CodeChef/FEB15/PRICECON.cpp b/CodeChef/FEB15/PRICECON.cpp new file mode 100644 index 0000000..6c8e658 --- /dev/null +++ b/CodeChef/FEB15/PRICECON.cpp @@ -0,0 +1,32 @@ +#include +using namespace std; +int main() +{ + int t; + cin >> t; + while (t--) + { + int sum1 = 0; + int sum2 = 0; + int n, k; + cin >> n >> k; + vector a; + for (int i = 0; i < n; i++) + { + int s; + cin >> s; + a.push_back(s); + } + for (int i = 0; i < n; i++) + sum1 += a[i]; + for (int i = 0; i < n; i++) + { + if (a[i] > k) + a[i] = k; + } + for (int i = 0; i < n; i++) + sum2 += a[i]; + cout << abs(sum1 - sum2) << endl; + } + return 0; +}