佳佳的魔法照片

佳佳的魔法照片

#include < iostream >
using   namespace  std;

struct  arr{
    
int  x,y;
}a[
50011 ];
int  n,m;
int  e[ 11 ];
int  cmp( const   void *  no1, const   void *  no2){
    arr 
* nox = (arr * )no1, * noy = (arr * )no2;
    
if (nox -> x != noy -> x)
        
return   - (nox -> x - noy -> x);
    
else
        
return  nox -> y - noy -> y;
}
void  hsort( int  s){
    a[
0 ] = a[s];
    
int  i = s * 2 ;
    
while (i <= n){
        
if (i + 1 <= n && a[i].x < a[i + 1 ].x || (a[i].x == a[i + 1 ].x && a[i].y > a[i + 1 ].y))
            i
++ ;
        
if (a[i].x > a[ 0 ].x){
            a[i
/ 2 ] = a[i];
            i
*= 2 ;
        }
        
else   break ;
    }
    a[i
/ 2 ] = a[ 0 ];
}
int  main()
{
    freopen(
" mphoto.in " , " r " ,stdin);
    freopen(
" mphoto.out " , " w " ,stdout);
    scanf(
" %d%d " , & n, & m);
    
for ( int  i = 1 ;i <= 10 ; ++ i)
        scanf(
" %d " , & e[i]);
    
for ( int  i = 1 ;i <= n; ++ i){
        scanf(
" %d " , & a[i].x);
        a[i].y
= i;
    }
    qsort(a
+ 1 ,n, sizeof (arr),cmp);
    
for ( int  i = 1 ;i <= n; ++ i){
        
int  c = (i - 1 ) % 10 + 1 ;
        a[i].x
+= e[c];
    }
    
for ( int  i = n / 2 ;i >= 1 ; -- i)
        hsort(i);
    
if (m) printf( " %d  " ,a[ 1 ].y);
    
while ( -- m > 0 ){
        a[
1 ] = a[n];
        n
-- ;
        hsort(
1 );
        
if (m != 1
            printf(
" %d  " ,a[ 1 ].y);
        
else
            printf(
" %d\n " ,a[ 1 ].y);
    }
    
return   0 ;
}




你可能感兴趣的:(佳佳的魔法照片)