-
Notifications
You must be signed in to change notification settings - Fork 3
/
Hackerrank_Cookies.c
53 lines (50 loc) · 1.08 KB
/
Hackerrank_Cookies.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
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
long long int n,k;
scanf("%lld %lld",n,k);
long long int aray[n];
int i;
for(i=0;i<n;i++){
scanf("%lld ",&aray[i]);
}
check(aray,n);
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}
void check(long long int aray[], long long int n){
int i;
for(i=0;i<n;i++){
if(aray[i]<7){
make_sweet(aray);
}
}
}
void make_sweet(long long int aray[]){
int least, sleast, i, n=(sizeof(aray)/sizeof(aray[0])), min=aray[0];
long long int naray[n];
int smin=naray[0];
for(i=0;i<n;i++){
if(aray[i]<min){
min=aray[i];
}
}
least=min;
for(i=0;i<n;i++){
naray[i]=aray[i];
if(naray[i]==min){
naray[i]='\0';
}
}
for(i=0;i<n;i++){
if(naray[i]<smin){
smin=aray[i];
}
}
sleast=smin;
for(i=0;i<n;i++){
aray[i]=(least+(2*sleast));
}
}