diff --git a/Codeforces/285C.cpp b/Codeforces/285C.cpp new file mode 100644 index 0000000..493cee1 --- /dev/null +++ b/Codeforces/285C.cpp @@ -0,0 +1,40 @@ +/* +*Problem Name (C. Building Permutation) + +*Problem Statement :- +You have a sequence of integers a1, a2, ..., an. In one move, you are allowed to decrease or increase any number by one. +Count the minimum number of moves, needed to build a permutation from this sequence. + +*/ + +#include +using namespace std; +typedef long long ll; + +int main(){ + + ll n;cin>>n; // ll is long long data type as defined above + ll arr[n]; + for(ll i=0; i>arr[i]; + } + + sort(arr,arr+n); //first we sort the array + ll diff =0, sum =0; + + for(ll i=0; i