From 51c6bee4ddf683438a93727fb93421cc9886f8e9 Mon Sep 17 00:00:00 2001 From: vmundra Date: Fri, 2 Oct 2020 15:38:50 +0530 Subject: [PATCH] added C++ solution to 285C Codeforces --- Codeforces/285C.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Codeforces/285C.cpp 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