-
Notifications
You must be signed in to change notification settings - Fork 0
/
C.c
57 lines (42 loc) · 719 Bytes
/
C.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/************************
Minimize The Sum
*************************/
#include<stdio.h>
#include<math.h>
#define MAX 9999
int main(int argc, char* argv[])
{
int N; // Size of the array
int K; // Maximum number of operation
int arr[MAX]; // The array of numbers
int sum=0;
int i,j,loc=0,temp=0;
scanf("%d",&N);
scanf("%d",&K);
// Condition Checking
if(N<1 || K>100000)
return 1;
else
{
// Reading the data
for(i=0;i<N;i++)
scanf("%d",&arr[i]);
}
for(i=0;i<K;i++)
{
temp=arr[0];
for(j=1;j<N;j++)
{
if(temp<arr[j])
{
temp=arr[j];
loc=j;
}
}
arr[loc]=(int)(arr[loc]/2);
}
for(i=0;i<N;i++)
sum=sum+arr[i];
printf("%d",sum);
return 0;
}