C. Counting Kangaroos is Fun 贪心
const int maxn = 500100; int s[maxn]; int main() { //freopen("in.txt","r",stdin); int n; while(cin>>n) { repf(i,1,n) scanf("%d",&s[i]); int ans = 0; sort(s+1,s+1+n); int j = n/2+1; for(int i = 1;i<=n/2&& j <= n;) { if(s[j] >= 2*s[i]) { ans++; i++; j++; }else { j++; } } cout<<ans + n - 2*ans<<endl; } return 0; }
posted on 2013-12-15 16:40 keep trying 阅读(423) 评论(0) 编辑 收藏 举报