补题:牛客寒假基础训练营 3

D-处女座的训练

贪心 long long

贪心,求最小疲惫值,安排一个做题顺序,首先要做的就是用时相对少但是同等时间产生的疲惫值多的题。按bi/ai排序。

注意的就是数据范围。要用long long

#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<string.h>
using namespace std;
struct test{
    int n,m;
    double w;
};
test a[100007];
bool cmp(test b,test c){
    return b.w>c.w;
}
int main(){
    int T;
    scanf("%d",&T);

    long long sum=0,ans=0;
    for(int i=0;i<T;i++){
        scanf("%d%d",&a[i].n,&a[i].m);
        a[i].w=1.0*a[i].m/a[i].n;
        sum+=a[i].m;
    }
    sort(a,a+T,cmp);
    for(int i=0;i<T;i++){
        sum-=a[i].m;
        ans+=sum*a[i].n;
    }
    printf("%lld",ans);
}

I-处女座的约会

思维题

从右侧砍,砍0,左侧随机出1或者0,所以一定会在有限次中出现0.所以答案唯一。

#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
int main(){
    int T;
    scanf("%d",&T);
    char str[1000];
    while(T--){
        scanf("%s",str);
        printf("cnznb\n");
    }
}

 

posted @ 2019-02-15 20:59  precious_LZY  阅读(97)  评论(0)    收藏  举报