|  | 
|  | 
| back to board | I'm getting insane!!!now wa#2, althought I've tested it whit an AC program here is my code. please help me :((
 #include <stdio.h>
 #define HMAX (1<<17)
 
 int N;
 unsigned int H[HMAX];
 
 void sift(int x)
 {
 int aux, up = x>>1;
 
 if (x < 1) return;
 
 if (H[x] > H[up])
 {
 aux = H[x]; H[x] = H[up]; H[up] = aux;
 sift(up);
 }
 }
 
 void perc(int x, int n)
 {
 int l = x<<1, r = (x<<1)+1, max, aux;
 
 if (r > n) return;
 
 max = l;
 if (H[l] < H[r]) max = r;
 
 if (H[max] > H[x])
 {
 aux = H[max]; H[max] = H[x]; H[x] = aux;
 perc(max, 1+N/2);
 }
 }
 
 int main()
 {
 int i, val;
 long double sol;
 unsigned int last, blast;
 
 //        freopen("1306.in", "r", stdin);
 scanf("%d", &N);
 
 H[0] = 4294967295;
 
 for (i = 1; i <= 1+(N/2); i++)
 scanf("%lu", H+i);
 for (i = 1; i <= 1+(N/2); i++) sift(i);
 
 for (i = 2+(N/2); i <= N; i++)
 {
 scanf("%d", &val);
 if (val < H[1]) { H[1] = val; perc(1, 1+(N/2)); }
 }
 
 
 blast = H[1];
 H[1] = 0;
 perc(1, (N/2));
 last = H[1];
 
 sol = last*0.5;
 sol += blast*0.5;
 if ( (N&1) == 0 ) printf("%0.1llf\n", sol);
 else printf("%u\n", blast);
 
 return 0;
 
 }
Re: I'm getting insane!!!now wa#2, althought I've tested it whit an AC program please help meRe: I'm getting insane!!!now wa#2, althought I've tested it whit an AC program Posted by AlMag  12 May 2007 19:24Try test with n=2.FE
 2
 10
 20
Re: I'm getting insane!!!now wa#2, althought I've tested it whit an AC program The result of my Program is 15.0How about you ??
Re: I'm getting insane!!!now wa#2, althought I've tested it whit an AC program In my opinion, test #2 contain data like this:1
 5
 
 Correct answer is:
 5.0
 
 I had a problem with output format. We should output the answer with one decimal digit after decimal point. My wrong program had written:
 5
 without fractional part.
 | 
 | 
|