codeforces372a

来源:互联网 发布:怎么自学编程 编辑:程序博客网 时间:2024/04/28 23:13

这个题吧,装袋鼠,必须体积是二倍才能装进去,你就给他分成两半,然后一个一个装,就过了,分成两拨是因为,如果一次加的话,本来能被装进去,但是装了人,导致,他不能了。。。反正就是占位置了,不好说,自己去yy一发就过了,这是个c题,div1的a

#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int MaxN = 5e5 + 100;int a[MaxN];int main(){    int t;    scanf("%d",&t);    for(int i = 0 ; i < t ; i++){        scanf("%d",&a[i]);    }    int l = 0 , r = t/2 , ans = 0;    sort(a , a + t);    int flag = 0;    while(l < t/2){        while(a[r] < 2*a[l] && r < t){            r++;        }        if(a[r] >= a[l]*2) {            ans++;            r++;        }        l++;    }    printf("%d\n",t - ans);}
0 0