2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem F. Finance 模拟题
Problem F. Finance
题目连接:
http://codeforces.com/gym/100714
Description
The Big Boss Company (BBC) principal is going to prepare a vacation schedule for the next year. Each
employee of BBC gets a four-week vacation each year. A vacation can be divided into several parts. Each
part consists of several weeks. The parts are separated by at least one work week.
According to the law, the pay for each vacation part is calculated separately from the others as follows.
Consider the employee’s salary for the period of 52 weeks preceding the current part of the vacation and
divide it by 52. (A year is assumed to consist of exactly 52 weeks.) All vacation pays during these 52
weeks are ignored for the purpose of salary calculation. The result is multiplied by the number of weeks
in this part of the vacation (ranging from 1 to 4).
Given the vacation schedules for the current year, you should help the BBC principal to construct the
next year’s schedule that minimizes the total vacation pay costs. Since the pays for distinct employees
are unrelated you are to solve the problem assuming that there is only one employee.
Input
The input contains four integers listed in the ascending order giving the vacation weeks in the current
year’s schedule. Weeks are specified by numbers ranging from 1 to 52.
Output
Output the numbers of vacation weeks for the next year in the ascending order. The vacation schedule
should minimize the vacation pay costs. If there are several equivalent solutions, output any of them.
Sample Input
2 3 20 21
Sample Output
1 2 3 5
Hint
题意
给你去年的假期安排,然后让你安排今年的假期,使得花费最少。
假期的花费是这样的,如果前面52天有一个假期的话,那么这一天的花费--
但是连着一起的话,就跟着算。
(我语文不好。。 还是自己读题吧 TAT
题解:
52^4枚举,然后再check就好了,check我用的树状数组,仔细一想,好像直接O(56)枚举,然后判断就好了……
代码
#include<bits/stdc++.h>
using namespace std;
const int maxn = 110;
int ans,ans1,ans2,ans3,ans4;
int ppp[maxn];
int lowbit(int x){
return x&(-x);
}
void update(int x,int v){
for(int i=x;i<maxn;i+=lowbit(i))
ppp[i]+=v;
}
int get(int x,int tmp=0){
if(x==0)return 0;
for(int i=x;i;i-=lowbit(i))
tmp+=ppp[i];
return tmp;
}
void cal(int x,int y,int z,int t){
int px=x,py=y,pz=z,pt=t;
if(y==x+1)y=x;
if(z==x+2)z=x;
if(z==y+1)z=y;
if(t==x+3)t=x;
if(t==y+2)t=y;
if(t==z+1)t=z;
update(px+52,1);
update(py+52,1);
update(pz+52,1);
update(pt+52,1);
int a1=get(x+51)-get(x-1);
int a2=get(y+51)-get(y-1);
int a3=get(z+51)-get(z-1);
int a4=get(t+51)-get(t-1);
int d[5];
d[1]=0,d[2]=0,d[3]=0,d[4]=0;
d[a1]++;
d[a2]++;
d[a3]++;
d[a4]++;
int sum = (52-a1)+(52-a2)+(52-a3)+(52-a4);
if(sum<ans){
ans=sum,ans1=px,ans2=py,ans3=pz,ans4=pt;
}
update(px+52,-1);
update(py+52,-1);
update(pz+52,-1);
update(pt+52,-1);
}
int main(){
//freopen("1.out","w",stdout);
int a,b,c,dd;
ans = 1e9;
scanf("%d%d%d%d",&a,&b,&c,&dd);
update(a,1);
update(b,1);
update(c,1);
update(dd,1);
cal(1,2,3,4);
for(int i=1;i<=52;i++){
for(int j=i+1;j<=52;j++){
for(int k=j+1;k<=52;k++){
for(int t=k+1;t<=52;t++){
cal(i,j,k,t);
}
}
}
}
cout<<ans1<<" "<<ans2<<" "<<ans3<<" "<<ans4<<endl;
}
2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem F. Finance 模拟题的更多相关文章
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem J. Joke 水题
Problem J. Joke 题目连接: http://codeforces.com/gym/100714 Description The problem is to cut the largest ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem H. Hometask 水题
Problem H. Hometask 题目连接: http://codeforces.com/gym/100714 Description Kolya is still trying to pass ...
- 2013-2014 ACM-ICPC, NEERC, Southern Subregional Contest Problem F. Judging Time Prediction 优先队列
Problem F. Judging Time Prediction 题目连接: http://www.codeforces.com/gym/100253 Description It is not ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem D. Distance 迪杰斯特拉
Problem D. Distance 题目连接: http://codeforces.com/gym/100714 Description In a large city a cellular ne ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem C. Contest 水题
Problem C. Contest 题目连接: http://codeforces.com/gym/100714 Description The second round of the annual ...
- 2016-2017 ACM-ICPC, NEERC, Moscow Subregional Contest Problem L. Lazy Coordinator
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229511 时间限制:1s 空间限制:512MB 题目大意: 给定一个n 随后跟着2n行输入 ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem K. KMC Attacks 交互题 暴力
Problem K. KMC Attacks 题目连接: http://codeforces.com/gym/100714 Description Warrant VI is a remote pla ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem I. Interest Targeting 模拟题
Problem I. Interest Targeting 题目连接: http://codeforces.com/gym/100714 Description A unique display ad ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem A. Alien Visit 计算几何
Problem A. Alien Visit 题目连接: http://codeforces.com/gym/100714 Description Witness: "First, I sa ...
随机推荐
- bzoj千题计划104:bzoj1013: [JSOI2008]球形空间产生器sphere
http://www.lydsy.com/JudgeOnline/problem.php?id=1013 设球心(x1,x2,x3……) 已知点的坐标为t[i][j] 那么 对于每个i满足 Σ (t[ ...
- Flex 编写 loading 组件
Flex 界面初始化有时那个标准的进度条无法显示,界面长时间会处理空白的状态!我们来自定义一个进度条, 这个进度条加载在 Application 应用程序界面的 <s:Application 标 ...
- 20155230 2016-2017-2 《Java程序设计》第五周学习总结
20155230 2016-2017-2 <Java程序设计>第五周学习总结 教材学习内容总结 1.错误处理通常称为异常处理. 2.catch括号中列出的异常不得有继承关系,否则会发生编译 ...
- [转]linux各文件夹介绍
本文来自linux各文件夹的作用的一个精简版,作为个人使用笔记. 下面简单看下linux下的文件结构,看看每个文件夹都是干吗用的? /bin 二进制可执行命令 /dev 设备特殊文件 /etc 系统管 ...
- MPC&MAGIC
MPC: Popularity-based Caching Strategy for Content Centric Networks MPC: most popular content MPC主要思 ...
- fish(自动推荐命令;语法高亮等)
Fish 是 Linux/Unix/Mac OS 的一个命令行 shell,有一些很好用的功能. 自动推荐 VGA 颜色 完美的脚本支持 基于网页的配置 帮助文档自动补全 语法高亮 以及更多 自动推荐 ...
- TP-Link wr703N 使用华为HiLink系列上网卡的设置【转】
转自:http://www.right.com.cn/forum/thread-103082-1-1.html 最近买了一个华为的E303s的上网卡,之前703的openwrt是按照需要拨号和使用U盘 ...
- python进阶之魔法函数
__repr__ Python中这个__repr__函数,对应repr(object)这个函数,返回一个可以用来表示对象的可打印字符串.如果我们直接打印一个类,向下面这样 class A(): ...
- 为你详细解读HTTP请求头的具体含意
当我们打开一个网页时,浏览器要向网站服务器发送一个HTTP请求头,然后网站服务器根据HTTP请求头的内容生成当次请求的内容发送给浏览器.你明白HTTP请求头的具体含意吗?下面一条条的为你详细解读,先看 ...
- spring boot JPA中实体类常用注解
spring boot jpa中的注解很多,参数也比较多.没必要全部记住,但是经常查看官方文档也比较麻烦,记录一下一些常用的注解.通过一些具体的例子来帮助记忆. @Entity @Table(name ...