bzoj4868
http://www.lydsy.com/JudgeOnline/problem.php?id=4868
三分+贪心
我们可以知道这是一个单峰函数
当A>B那么我们每次调整一个的价钱是最佳的,所以全部用B,如果A<B,那么我们尽量用A,不行再用B
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ;
int n, m;
ll A, B, C;
ll b[N], t[N];
ll check(ll T)
{
ll tot1 = , tot2 = , cost = ;
for(int i = ; i <= m; ++i) if(b[i] > T) tot1 += b[i] - T; else tot2 += T - b[i];
for(int i = ; i <= n; ++i) if(t[i] < T) cost += C * (T - t[i]);
if(A > B) cost += tot1 * B; else cost += min(tot1, tot2) * A + (tot1 - min(tot1, tot2)) * B;
return cost;
}
int main()
{
scanf("%lld%lld%lld", &A, &B, &C);
scanf("%d%d", &n, &m);
for(int i = ; i <= n; ++i) scanf("%lld", &t[i]);
for(int i = ; i <= m; ++i) scanf("%lld", &b[i]);
if(C >= 10000000000000000ll)
{
ll lim = 10000000000000000ll;
for(int i = ; i <= n; ++i) lim = min(lim, t[i]);
printf("%lld\n", check(lim));
return ;
}
ll l = , r = ;
while(r - l > )
{
ll lm = ( * l + r) / , rm = ( * r + l) / ;
ll val1 = check(lm), val2 = check(rm);
if(val1 > val2) l = lm; else r = rm;
}
printf("%lld\n", min(min(check(( * l + r) / ), check(( * r + l) / )), min(check(l), check(r))));
return ;
}
bzoj4868的更多相关文章
- 【BZOJ4868】[六省联考2017]期末考试(贪心)
[BZOJ4868][六省联考2017]期末考试(贪心) 题面 BZOJ 洛谷 题解 显然最终的答案之和最后一个公布成绩的课程相关. 枚举最后一天的日期,那么维护一下前面有多少天可以向后移,后面总共需 ...
- BZOJ4868 [Shoi2017]期末考试 【三分 + 贪心】
题目链接 BZOJ4868 题解 最后的答案决定于最后一个公布的成绩 显然这个是答案关于这个时间点是呈凸单调的 三分一下这个时间点 时间点固定,在这个时间前的人都会产生不愉快度,在这个时间前的科目可以 ...
- BZOJ4868 Shoi2017期末考试(三分+贪心)
容易想到枚举最晚发布成绩的课哪天发布,这样与ti和C有关的贡献固定.每门课要么贡献一些调节次数,要么需要一些调节次数,剩下的算贡献也非常显然.这样就能做到平方级别了. 然后大胆猜想这是一个凸函数三分就 ...
- 【BZOJ4868】期末考试(整数三分)
题意: 有n位同学,每位同学都参加了全部的m门课程的期末考试,都在焦急的等待成绩的公布.第i位同学希望在第ti天 或之前得知所.有.课程的成绩.如果在第ti天,有至少一门课程的成绩没有公布,他就会等待 ...
- [bzoj4868][Shoi2017]期末考试
来自FallDream 的博客,未经允许,请勿转载,谢谢. 有n位同学,每位同学都参加了全部的m门课程的期末考试,都在焦急的等待成绩的公布.第i位同学希望在第ti天或之前得知所.有.课程的成绩.如果在 ...
- bzoj千题计划262:bzoj4868: [六省联考2017]期末考试
http://www.lydsy.com/JudgeOnline/problem.php?id=4868 假设 最晚出成绩的是第i天 预处理 cnt[i] 表示 有多少个学生 期望出成绩的那一天 &l ...
- [BZOJ4868][六省联考2017]期末考试(三分)
4868: [Shoi2017]期末考试 Time Limit: 20 Sec Memory Limit: 512 MBSubmit: 964 Solved: 439[Submit][Status ...
- BZOJ4868:[SHOI2017]期末考试——题解
http://www.lydsy.com/JudgeOnline/problem.php?id=4868 题目复制于洛谷:https://www.luogu.org/problemnew/show/P ...
- 【BZOJ4868】期末考试 [三分][贪心]
期末考试 Time Limit: 20 Sec Memory Limit: 512 MB[Submit][Status][Discuss] Description Input Output Samp ...
- 【bzoj4868】期末考试
我还第一次见到省选考三分……? #include<bits/stdc++.h> #define N 200005 using namespace std; typedef long lon ...
随机推荐
- Linux 搭建 squid 代理服务器 三种模式
CentOS 6.7 squid 代理服务器 一般有两张或以上网卡,一张链接公网,访问外网资源,一张位于局域网. 代理服务器可以提供文件缓存.复制和地址过滤等服务,充分利用有限的出口带宽,加快内部主机 ...
- LeetCode(38) Count and Say
题目 The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111 ...
- 数据导出Excel,动态列
今天碰到一个需求,要求将用户回答的问卷及问题导出Excel表格,问卷对应的问题数量不一致,需要动态添加列表头,简单记录. 要导出Excel需要添加poi.jar包 用户-问卷实体(固定列): pack ...
- 找出消耗CPU最高的进程对应的SQL语句
COLUMN PID FORMAT 999COLUMN S_# FORMAT 999COLUMN USERNAME FORMAT A9 HEADING "ORA USER"COLU ...
- poj 1456
#include<stdio.h> #include<string.h> #include<stdlib.h> #define N 10010 #define in ...
- 【bzoj3747】[POI2015]Kinoman - 线段树(经典)
Description 共有m部电影,编号为1~m,第i部电影的好看值为w[i]. 在n天之中(从1~n编号)每天会放映一部电影,第i天放映的是第f[i]部. 你可以选择l,r(1<=l< ...
- 无法打开物理文件 "X.mdf"。操作系统错误 5:"5(拒绝访问。)"。 (Microsoft SQL Server,错误: 5120)解决
环境 SQLServer 2008 R2 问题 附加数据库出现“无法打开物理文件 "X.mdf".操作系统错误 5:"5(拒绝访问.)". (Microsoft ...
- Ice Cave-CodeForces(广搜)
链接:http://codeforces.com/problemset/problem/540/C You play a computer game. Your character stands on ...
- CODEFORCES problem 105A.Transmigration
题目本身上手并不难,字符串处理+简单的排序.要注意的地方是浮点数的处理. 依据计算机中浮点数的表示原理,在实际编程的过程中即使用一个确定的整数(假设是1)给一个浮点变量赋值 在查看变量时会发现实际存储 ...
- Add Two Numbers(链表)
You are given two linked lists representing two non-negative numbers. The digits are stored in rever ...