zoukankan      html  css  js  c++  java
  • 【[六省联考2017]期末考试】

    题目

    听说正解是三分

    但是这不是普及级别的模拟吗,我觉得这道题其实放到普及(T2)好像也非常自然

    发现(t)最大也就只有(1e5),我们可以直接枚举最晚的完成时间

    之后我们就可以算一下那些要求在这一天之前就发成绩学生们产生的不愉快值

    之后对于那些本来应该在这之前完成的工作我们算一下这些一共能有多少支援后边的,也算一下后面的需要多少才能都变到当前枚举的这一天完成,我们贪心调整它们平衡就好了

    至于如何快速计算这些东西呢,排个序开个指针扫一遍就好了

    代码

    #include<algorithm>
    #include<iostream>
    #include<cstring>
    #include<cstdio>
    #define re register
    #define maxn 100005
    #define LL unsigned long long
    #define min(a,b) ((a)<(b)?(a):(b))
    inline int read()
    {
    	char c=getchar();int x=0;
    	while(c<'0'||c>'9') c=getchar();
    	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+c-48,c=getchar();return x;
    }
    int t[maxn],b[maxn];
    int n,m,num,sz;
    LL A,B,C;
    LL cnt,ans=1ll<<62ll,S,tot;
    int main()
    {
    	scanf("%lld%lld%lld",&A,&B,&C);
    	if(A>B) A=B;
    	n=read(),m=read();
    	for(re int i=1;i<=n;i++) t[i]=read();
    	for(re int i=1;i<=m;i++) b[i]=read(),tot+=b[i];
    	std::sort(t+1,t+n+1),std::sort(b+1,b+m+1);
    	for(re int i=1;i<=b[m];i++)
    	{
    		while(t[num+1]==i) num++,S+=i;
    		while(b[sz+1]==i) sz++,cnt+=i,tot-=i;
    		LL now=num*(LL)i-S;now*=C;
    		LL d=sz*(LL)i-(LL)cnt,w=tot-(LL)i*((LL)m-(LL)sz);
    		if(w) 
    		{
    			if(d>w) now+=w*A;
    			else now+=d*A+B*(w-d);
    		}
    		ans=min(ans,now);
    	}
    	printf("%lld
    ",ans);
    	return 0;
    }
    
  • 相关阅读:
    beta冲刺(6/7)
    beta冲刺(5/7)
    beta冲刺(4/7)
    beta(3/7)
    beta冲刺(2/7)
    beta冲刺(1/7)
    团队项目测评博客
    东华理工18级计科五班团队作业六
    东华理工18级计科五班团队作业五
    东华理工18级计科五班团队作业四
  • 原文地址:https://www.cnblogs.com/asuldb/p/10300700.html
Copyright © 2011-2022 走看看