Algorithm
Code Examples
#1 Code Example with C++ Programming
Code -
C++ Programming
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--){
int n, k;
cin>>n>>k;
int x, sum = 0;
for(int i = 0; i < n; i++){
cin>>x;
sum += x;
}
if(sum - k <= 0){
cout<<0<<endl;
}
else{
cout<<(sum-k)<<endl;
}
}
}
Copy The Code &
Try With Live Editor
Input
3
3 1
1 2 1
4 5
3 3 5 2
5 16
1 2 3 4 5
3 1
1 2 1
4 5
3 3 5 2
5 16
1 2 3 4 5
Output
3
8
0
8
0
Demonstration
Codeforcess Solution 1697-A A. Parkway Walk ,C++, Java, Js and Python ,1697-A,Codeforcess Solution