It would be better if you format and use proper indentation while posting codes. Posting the code in a paragraph makes it unreadable and impossible to debug.
If you use the phrase that work was a cakewalk or that mission was a cakewalk that means the work was a piece of cake. UK dissertation help Simply accomplished with little or no effort. You six guys! Go carry that Ping-Pong table to the other side of the room = cakewalk. Yo, Fred! Carry the slate pool table up those stairs = not a cakewalk.
You looking for Dentist in Jaipur. We have become a symbol of quality and Endeavour Our self to provide high standards of dental treatment to our patients. We have high standards of sterilization with International sterilization protocols followed . We follow three Phase Sterilization as recommended by American Dental Association. Ekdantam Dental clinic
We provide the best jaipur sightseeing taxi with Facilities and healthy Relations for Future Bookings.kdcab is here to provide the best experience of traveling of your trip with reliable and affordable cab service in Jaipur.
hello why don’t you give if the editorial says you can accept within time with a binary search???
#include
#include
#include
using namespace std;
#define MAX 101
int medio;
int binary_search(int *vec,int i,int j,int m){
if(i>j)return -1;
medio = (i+j)/2;
if(m>vec[medio])return binary_search(vec,medio+1,j,m);
else if(m<vec[medio])return binary_search(vec,i,j-1,m);
else medio;
}
int main(int argc,char *argv[],char **env){
int t,n,k,val;
scanf("%d",&t);
while(t--){
scanf("%d",&n);
int vec[MAX]{};
for(int i=1;i<=n;i++)
scanf("%d",(vec+i));
scanf("%d",&k);
val = vec[k];
sort(vec+1,vec+n+1);
printf("%d\n",binary_search(vec,1,n,val));
}
return 0;
}
Why is thi code giving wrong answer??
#include<stdio.h>
int main()
{
int t,n,m,k,i,j;
long long int a[100],b,temp;
scanf("%d",&t);
while (t–)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%lld",&a[i]);
}
scanf("%d",&k);
b = a[k-1];
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
for(i=0;i<n;i++)
{
if(a[i]== b)
printf("%d",i+1);
}
}
return 0;
}
#include
#include
using namespace std;
void fastscan(int &number)
{
//variable to indicate sign of input number
bool negative = false;
register int c;
number = 0;
c = getchar();
if (c=='-')
{
// number is negative
negative = true;
c = getchar();
}
for (; (c>47 && c<58); c=getchar())
number = number *10 + c - 48;
if (negative)
number *= -1;
}
int main()
{
int a;
fastscan(a);
while(a–)
{
int b;
fastscan(b);
int l[b];
for(int i=0;i<b;i++)
{
fastscan(l[i]);
}
int y;
fastscan(y);
int u=l[y-1];int o=0;
for(int i=0;i<b;i++)
{
if(u>=l[i])
{
o++;
}
}
cout<<o+1<<endl;
}
}
#include
#include
using namespace std;
void fastscan(int &number)
{
//variable to indicate sign of input number
bool negative = false;
register int c;
number = 0;
c = getchar();
if (c=='-')
{
// number is negative
negative = true;
c = getchar();
}
for (; (c>47 && c<58); c=getchar())
number = number *10 + c - 48;
if (negative)
number *= -1;
}
int main()
{
int a;
fastscan(a);
while(a–)
{
int b;
fastscan(b);
int l[b];
for(int i=0;i<b;i++)
{
fastscan(l[i]);
}
int y;
fastscan(y);
int u=l[y-1];int o=0;
for(int i=0;i<b;i++)
{
if(u>=l[i])
{
o++;
}
}
cout<<o+1<<endl;
}
}