Click here to Skip to main content
15,898,987 members

Comments by NISHANK BABU (Top 6 by date)

NISHANK BABU 26-May-21 3:40am View    
i didn't get u..
NISHANK BABU 26-May-21 3:26am View    
#include <stdio.h>
#define min(x,y) (x <= y ? x : y)
#define max(x,y) (x <= y ? x : y)

int main()
{
int t;
scanf("%d",&t);
while (t--)
{
int n, a, b;
scanf("%d%d%d",&n,&a,&b);

int x = min(a, b);
int y = max(a, b);
int ans = n;

for (int i = x; i < y; i++)
{
int temp = max((i - 1) + min(x - 1, i - x), (n - i - 1) + min(n - y, y - i - 1));
ans = min(ans, temp);
}

printf(ans,"\n");
}
}
error
timeout: the monitored command dumped core
NISHANK BABU 26-May-21 3:25am View    
Deleted
#include <stdio.h>
#define min(x,y) (x <= y ? x : y)
#define max(x,y) (x <= y ? x : y)

int main()
{
int t;
scanf("%d",&t);
while (t--)
{
int n, a, b;
scanf("%d%d",&n,&a,&b);

int x = min(a, b);
int y = max(a, b);
int ans = n;

for (int i = x; i < y; i++)
{
int temp = max((i - 1) + min(x - 1, i - x), (n - i - 1) + min(n - y, y - i - 1));
ans = min(ans, temp);
}

printf(ans,"\n");
}
}
error
timeout: the monitored command dumped core
NISHANK BABU 9-May-21 12:04pm View    
Deleted
It's working thank you soo much
NISHANK BABU 9-May-21 0:33am View    
Deleted
I had given the inputs as
3
0709
1337
246432
Correct output is
0079
1337
234642
What I got is
0
0079
234642

Can u say me ur logic for this..plz