Skip to main content
Code Review

Return to Question

added 107 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

How do I decrease time, speciallyespecially in sorting?

Given a list of numbers, you are to sort them in non-decreasing order.

Input

t – the number of numbers in list, then t lines follow [\$t <= 10^6\$].

Each line contains one integer: N [\0ドル <= N <= 10^6\$]

Output

Output given numbers in non-decreasing order.

Example

Input: 5 5 3 6 7 1

Output: 1 3 5 6 7

Given a list of numbers, you are to sort them in non-decreasing order.

Input

t – the number of numbers in list, then t lines follow [\$t \le 10^6\$].

Each line contains one integer: N [\0ドル \le N \le 10^6\$]

Output

Given numbers in non-decreasing order.

Example

Input:

5
5
3
6
7
1

Output:

1
3
5
6
7

How do I decrease time, specially in sorting?

Given a list of numbers, you are to sort them in non-decreasing order.

Input

t – the number of numbers in list, then t lines follow [\$t <= 10^6\$].

Each line contains one integer: N [\0ドル <= N <= 10^6\$]

Output

Output given numbers in non-decreasing order.

Example

Input: 5 5 3 6 7 1

Output: 1 3 5 6 7

How do I decrease time, especially in sorting?

Given a list of numbers, you are to sort them in non-decreasing order.

Input

t – the number of numbers in list, then t lines follow [\$t \le 10^6\$].

Each line contains one integer: N [\0ドル \le N \le 10^6\$]

Output

Given numbers in non-decreasing order.

Example

Input:

5
5
3
6
7
1

Output:

1
3
5
6
7
Formatting.
Source Link
Brythan
  • 7k
  • 3
  • 22
  • 37

How do I decrease compile time Sort and execution time of following sorting program?display input numbers

this was the easiest way i could find to solve the problem. howHow do iI decrease time, specially in sorting.?

Given thea list of numbers, you are to sort them in non decreasing-decreasing order. Input

Input

t – the number of numbers in list, then t lines follow [t <= 10^6][\$t <= 10^6\$].

Each line contains one integer: N [0 <= N <= 10^6] Output[\0ドル <= N <= 10^6\$]

Output

Output given numbers in non decreasing-decreasing order. Example

Example

Input: 5 5 3 6 7 1 Output

Output: 1 3 5 6 7

How do I decrease compile time and execution time of following sorting program?

this was the easiest way i could find to solve the problem. how do i decrease time, specially in sorting.

Given the list of numbers, you are to sort them in non decreasing order. Input

t – the number of numbers in list, then t lines follow [t <= 10^6].

Each line contains one integer: N [0 <= N <= 10^6] Output

Output given numbers in non decreasing order. Example

Input: 5 5 3 6 7 1 Output: 1 3 5 6 7

Sort and display input numbers

How do I decrease time, specially in sorting?

Given a list of numbers, you are to sort them in non-decreasing order.

Input

t – the number of numbers in list, then t lines follow [\$t <= 10^6\$].

Each line contains one integer: N [\0ドル <= N <= 10^6\$]

Output

Output given numbers in non-decreasing order.

Example

Input: 5 5 3 6 7 1

Output: 1 3 5 6 7

Source Link

How do I decrease compile time and execution time of following sorting program?

this was the easiest way i could find to solve the problem. how do i decrease time, specially in sorting.

Given the list of numbers, you are to sort them in non decreasing order. Input

t – the number of numbers in list, then t lines follow [t <= 10^6].

Each line contains one integer: N [0 <= N <= 10^6] Output

Output given numbers in non decreasing order. Example

Input: 5 5 3 6 7 1 Output: 1 3 5 6 7

struct sort_list{
int num;
struct sort_list *next;
};
typedef struct sort_list node;
void enter();
void sort();
void print();
int main()
{
 node *head;
 int tot_num;
 scanf("%d",&tot_num); //asking for entering total numbers
 head=(node*)malloc(sizeof(node));
 enter(head,tot_num);
 sort(head,tot_num);
 print(head);
 return 0;
 }
 void enter(node *list,int tot_num)
 {
 int i=0;
 while(i!=tot_num)
 {
 scanf("%d",&list->num); 
 if(i==tot_num-1)
 {
 list->next=0;
 //break;
 }
 else
 {
 list->next=(node*)malloc(sizeof(node)); 
 list=list->next;
 }
 i++;
 }
 }
 void print(node *list)
 {
 int i=0;
 while(list->next!=0)
 {
 printf("%d\n",list->num);
 list=list->next;
 i++;
 }
 if(list->next==0)
 {
 printf("%d\n",list->num);
 }
 }
 void sort(node *list,int tot_num)
 {
 node *new=list;
 int i,j,t;
 for(i=0;i<tot_num;i++)
 {
 for(j=i+1;j<tot_num;j++)
 { 
 if(list->num > list->next->num)
 {
 t=list->num;
 list->num=list->next->num;
 list->next->num=t;
 }
 list=list->next;
 }
 list=new;
 }
 }
lang-c

AltStyle によって変換されたページ (->オリジナル) /