ZROI#986
曾经\(wqy\) 在校内模拟赛给我们出过这么一道题.
但我完全没想起来怎么做,于是就只能瞎贪.
然后\(10pts\)走人了....
你考虑,假定答案是\(k\),那么一定是最大的\(k\)个和最小的\(k\)袋鼠配对.
从大到小贪心即可.
\(Code:\)
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define per(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define pii pair < int , int >
#define X first
#define Y second
#define rint read<int>
#define int long long
#define pb push_back
using std::queue ;
using std::set ;
using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;
using std::swap ;
using std::sort ;
using std::unique ;
using std::greater ;
template < class T >
inline T read () {
T x = 0 , f = 1 ; char ch = getchar () ;
while ( ch < '0' || ch > '9' ) {
if ( ch == '-' ) f = - 1 ;
ch = getchar () ;
}
while ( ch >= '0' && ch <= '9' ) {
x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
ch = getchar () ;
}
return f * x ;
}
const int N = 1e6 + 100 ;
int n , v[N] , ans ;
signed main (int argc , char * argv[]) {
n = rint () ;
for (int i = 1 ; i <= n ; ++ i) v[i] = rint () ;
std::sort ( v + 1 , v + n + 1 ) ;
int cur = n , p = ( n >> 1 ) ;
while ( true ) {
if ( v[p] * 2 <= v[cur] ) ++ ans , -- cur ;
if ( cur <= ( n >> 1 ) ) break ;
-- p ; if ( ! p ) break ;
}
printf ("%d\n" , ans ) ;
return 0 ;
}
May you return with a young heart after years of fighting.