Language: C



#include <stdio.h>
#define H 500000
  
int A[H],n;
 
void maxHeapify(int *A,int i){
 
  int largest,l,r,temp;
 
  l = 2*i;
  r = (2*i)+1;
 
  if(l<=n && A[l]>A[i])
    largest = l;
  else
    largest = i;
 
  if(r<=n && A[r]>A[largest])
    largest = r;
   
  if(largest != i){
    temp = A[i];
    A[i] = A[largest];
    A[largest] = temp;
    maxHeapify(A,largest);
  }
}
 
void buildMaxHeap(int *A){
 
  int i;
 
  for(i=n/2;i>0;i--){
    maxHeapify(A,i);
  }
}
 
 
int main(void){
  
  int k,p,l,r,i;
 
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
    buildMaxHeap(A);
 
  for(i=1;i<=n;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}
Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 6/6 	C 	CPU: 00.10 sec 	Memory: 2552 KB 	Length: 662 B 	2015-06-19 10:36 	2015-06-19 10:36
Results for testcases
Case # 	Verdict 	CPU Time 	Memory 	In 	Out 	Case Name
Case #1: 	: Accepted 	00.00 sec 	600 KB 	8 B 	7 B 	1.in
Case #2: 	: Accepted 	00.00 sec 	600 KB 	30 B 	28 B 	2.in
Case #3: 	: Accepted 	00.00 sec 	600 KB 	62 B 	60 B 	3.in
Case #4: 	: Accepted 	00.00 sec 	596 KB 	296 B 	293 B 	4.in
Case #5: 	: Accepted 	00.00 sec 	604 KB 	3898 B 	3894 B 	5.in
Case #6: 	: Accepted 	00.10 sec 	2552 KB 	3388902 B 	3388896 B 	6.in
< prev | 	1 	/ 	6 	| next > 	  		 : Accepted        00.00 sec        600 KB
 
Judge Input #1 ( in1.txt | 8 B) 		Judge Output #1 ( out1.txt | 7 B)

3
1 2 3

		

 3 2 1

Comments
 
 Under Construction.
 
Categories
 
 
Free Tags
 
 

Compiler output:
main.c:58:1: error: unknown type name 'Compile'
   58 | Compile Error Logs:
      | ^~~~~~~
main.c:58:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Logs'
   58 | Compile Error Logs:
      |               ^~~~
main.c:64:6: error: stray '#' in program
   64 | Case #  Verdict         CPU Time        Memory  In      Out     Case Name
      |      ^
main.c:65:6: error: stray '#' in program
   65 | Case #1:        : Accepted      00.00 sec       600 KB  8 B     7 B     1.in
      |      ^
main.c:65:73: error: invalid suffix "in" on floating constant
   65 | Case #1:        : Accepted      00.00 sec       600 KB  8 B     7 B     1.in
      |                                                                         ^~~~
main.c:66:6: error: stray '#' in program
   66 | Case #2:        : Accepted      00.00 sec       600 KB  30 B    28 B    2.in
      |      ^
main.c:66:73: error: invalid suffix "in" on floating constant
   66 | Case #2:        : Accepted      00.00 sec       600 KB  30 B    28 B    2.in
      |                                                                         ^~~~
main.c:67:6: error: stray '#' in program
   67 | Case #3:        : Accepted      00.00 sec       600 KB  62 B    60 B    3.in
      |      ^
main.c:67:73: error: invalid suffix "in" on floating constant
   67 | Case #3:        : Accepted      00.00 sec       600 KB  62 B    60 B    3.in
      |                                                                         ^~~~
main.c:68:6: error: stray '#' in program
   68 | Case #4:        : Accepted      00.00 sec       596 KB  296 B   293 B   4.in
      |      ^
main.c:68:73: error: invalid suffix "in" on floating constant
   68 | Case #4:        : Accepted      00.00 sec       596 KB  296 B   293 B   4.in
      |                                                                         ^~~~
main.c:69:6: error: stray '#' in program
   69 | Case #5:        : Accepted      00.00 sec       604 KB  3898 B  3894 B  5.in
      |      ^
main.c:69:73: error: invalid suffix "in" on floating constant
   69 | Case #5:        : Accepted      00.00 sec       604 KB  3898 B  3894 B  5.in
      |                                                                         ^~~~
main.c:70:6: error: stray '#' in program
   70 | Case #6:        : Accepted      00.10 sec       2552 KB         3388902 B       3388896 B       6.in
      |      ^
main.c:70:97: error: invalid suffix "in" on floating constant
   70 | Case #6:        : Accepted      00.10 sec       2552 KB         3388902 B       3388896 B       6.in
      |                                                                                                 ^~~~
main.c:73:13: error: stray '#' in program
   73 | Judge Input #1 ( in1.txt | 8 B)                 Judge Output #1 ( out1.txt | 7 B)
      |             ^
main.c:73:62: error: stray '#' in program
   73 | Judge Input #1 ( in1.txt | 8 B)                 Judge Output #1 ( out1.txt | 7 B)
      |                                                              ^