472B : Design Tutorial: Learn from Life

 

#Solutions

#include <bits/stdc++.h>
using namespace std;
int main() {
int b,c,tmp,n,k;
int sum=0;

cin>>n>>k;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
for(int i=n-1;i>=0;i-=k)
{
sum+=(a[i]-1)*2;     //1st floor to n-1 floor
}
cout<<sum<<endl;
}

Advertisements

About waprogramming

I am in CSE,from CUET
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s