Gym 101606 - A/B/C/D/E/F/G/H/I/J/K/L - (Undone)
链接:https://codeforces.com/gym/101606
A - Alien Sunset
暴力枚举小时即可。
#include<bits/stdc++.h>
using namespace std;
const int maxn=;
int n;
int h[maxn],r[maxn],s[maxn];
inline bool dark(int id,int time)
{
if(r[id]<s[id])
{
if(r[id]<time && time<s[id]) return ;
else return ;
}
if(r[id]>s[id])
{
if(s[id]<=time && time<=r[id]) return ;
else return ;
}
}
int main()
{
cin>>n;
int mx=;
for(int i=;i<=n;i++) cin>>h[i]>>r[i]>>s[i], mx=max(h[i],mx); for(int time=;time<mx*;time++)
{
bool ok=;
for(int i=;i<=n;i++) if(!dark(i,time%h[i])) ok=;
if(ok)
{
cout<<time<<endl;
return ;
}
}
cout<<"impossible"<<endl;
}
B - Breaking Biscuits - (Undone)
C - Cued In - [水]
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
map<string,int> mp;
int main()
{
ios::sync_with_stdio();
cin.tie(), cout.tie(); mp["red"]=,
mp["yellow"]=,
mp["green"]=,
mp["brown"]=,
mp["blue"]=,
mp["pink"]=,
mp["black"]=; cin>>n;
int red=, sum=, mx=;
for(int i=;i<=n;i++)
{
cin>>s;
mx=max(mx,mp[s]);
if(s=="red") red++;
else sum+=mp[s];
} if(red==n) cout<<"1\n";
else if(red==) cout<<sum<<'\n';
else cout<<red*(mx+)+sum<<'\n';
}
D - Deranging Hat - (Undone)
E - Education - [贪心]
$O(n^2)$ 时间复杂度的贪心。
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define fi first
#define se second
const int maxn=5e3+; int n,m;
P s[maxn];
int ans[maxn]; struct F{
int id;
int capa,rent;
bool operator<(const F& o)
{
return capa>o.capa;
}
}f[maxn];
bool vis[maxn]; int main()
{
cin>>n>>m;
for(int i=;i<=n;i++) scanf("%d",&s[i].fi), s[i].se=i;
sort(s+,s+n+,greater<P>{}); //for(int i=1;i<=n;i++) printf("%d %d\n",s[i].fi,s[i].se); for(int i=;i<=m;i++) f[i].id=i;
for(int i=;i<=m;i++) scanf("%d",&f[i].capa);
for(int i=;i<=m;i++) scanf("%d",&f[i].rent);
sort(f+,f+m+); //for(int i=1;i<=m;i++) printf("%d: %d %d\n",f[i].id,f[i].capa,f[i].rent); memset(vis,,sizeof(vis));
memset(ans,,sizeof(ans));
for(int i=;i<=n;i++)
{
int mn=1e3+, mnid=;
for(int j=;j<=m && f[j].capa>=s[i].fi;j++)
{
if(vis[j]) continue;
if(f[j].rent<mn)
{
mn=f[j].rent;
mnid=j;
}
}
vis[mnid]=;
ans[s[i].se]=f[mnid].id;
}
bool ok=;
for(int i=;i<=n;i++) if(ans[i]==) ok=;
if(ok) for(int i=;i<=n;i++) printf("%d ",ans[i]);
else printf("impossible");
cout<<endl;
}
F - Flipping Coins - [概率DP]
H - Hiking - (Undone)
I - I Work All Day - (Undone)
J - Just A Minim - [水]
#include<bits/stdc++.h>
using namespace std;
int n;
double t[];
int main()
{
t[]=2.0;
t[]=1.0;
t[]=1.0/2.0;
t[]=1.0/4.0;
t[]=1.0/8.0;
t[]=1.0/16.0; cin>>n;
double res=0.0;
for(int i=,x;i<=n;i++)
{
scanf("%d",&x);
res+=t[x];
}
printf("%.7f\n",res);
}
L - Lizard Lounge - [计算几何+LIS]
Gym 101606 - A/B/C/D/E/F/G/H/I/J/K/L - (Undone)的更多相关文章
- codeforces gym 100952 A B C D E F G H I J
gym 100952 A #include <iostream> #include<cstdio> #include<cmath> #include<cstr ...
- codeforces gym101243 A C D E F G H J
gym101243 A #include<iostream> #include<cstdio> #include<cmath> #include<cstrin ...
- 2017-2018 ACM-ICPC, NEERC, Southern Subregional Contest A E F G H I K M
// 深夜补水题,清早(雾)写水文 A. Automatic Door 题意 \(n(n\leq 1e9)\)个\(employee\)和\(m(m\leq 1e5)\)个\(client\)要进门, ...
- The 16th Zhejiang Provincial Collegiate Programming Contest Sponsored(E F G H I)
http://acm.zju.edu.cn/onlinejudge/showContestProblems.do?contestId=392 E:Sequence in the Pocket 思路:从 ...
- 2016CCPC长春 - B/D/F/H/I/J/K - (待补)
目录: B - Fraction D - Triangle F - Harmonic Value Description H - Sequence I I - Sequence II B题:HDU 5 ...
- Codeforces 1214 F G H 补题记录
翻开以前打的 #583,水平不够场上只过了五题.最近来补一下题,来记录我sb的调试过程. 估计我这个水平现场也过不了,因为前面的题已经zz调了好久-- F:就是给你环上一些点,两两配对求距离最小值. ...
- 2017 United Kingdom and Ireland Programming(Gym - 101606)
题目很水.睡过了迟到了一个小时,到达战场一看,俩队友AC五个了.. 就只贴我补的几个吧. B - Breaking Biscuits Gym - 101606B 旋转卡壳模板题.然后敲错了. 代码是另 ...
- ThinkPHP内置函数详解D、F、S、C、L、A、I
单字母函数D.F.S.C.L.A.I 他们都在ThinkPHP核心的ThinkPHP/Mode/Api/functions.php这个文件中定义. 下面我分别说明一下他们的功能: D() 加载Mode ...
- The value for the useBean class attribute is invalied
JSP: The value for the useBean class attribute XXX is ...
随机推荐
- 封装ajax,让调用变得简单优化
思考一下: 通常我们在使用ajax来发送接口请求时,每一次都会调用ajax固定的元素,比如data.url.method.success.error等.那么我们想一下能不能先把ajax封装起来,在每次 ...
- WebService - 术语介绍
一.WebService是什么? 1. 基于Web的服务:服务器端整出一些资源让客户端应用访问(获取数据) 2. 一个跨语言.跨平台的规范(抽象) 3. 多个跨平台.跨语言的应用间通信整合的方案(实际 ...
- TIME_WAIT 太多的解决办法
TIME_WAIT 客户端与服务器端建立TCP/IP连接后关闭SOCKET后,服务器端连接的端口状态为TIME_WAIT.主动关闭的一方在发送最后一个 ack 后 就会进入 TIME_WAIT 状态 ...
- RequireJS - 个人小入门
quirejs : http://www.requirejs.cn/ 叶小钗 : http://www.cnblogs.com/yexiaochai/p/3214926.html app.js 展示 ...
- vue-地址插件 v-region
demo地址:https://terryz.gitee.io/vue/#/region/demo
- Hive快捷查询:不启用Mapreduce job启用Fetch task三种方式介绍
如果查询表的某一列,Hive中默认会启用MapReduce job来完成这个任务,如下: hive>select id,name from m limit 10;--执行时hive会启用MapR ...
- linux下安装redis并开机自启动
分享一个博客地址, 写的太好了, 满满的都是干货 ! https://www.cnblogs.com/renzhicai/p/7773080.html
- eclipse打开工作空间(workspace)没有任务反应
删除workspace下的.metadata文件夹,重新打开Eclipse就OK了.
- Linux 上使用LVM 扩展磁盘Size
第一步:使用 fdisk -l 查看当前磁盘容量 fdisk -l 第二步: 使用 fdisk /dev/sda/ 为free space 添加新的分区 fdisk /dev/sda m :列出所有命 ...
- 自己总结的C#编码规范--7.文档下载 & 总结
今天终于把这一系列的编码规范写完了,这个编码规范算上前面阅读相关书籍,前前后后总共花了一个月的时间,也算是个人的呕心沥血之作了. 本来也没打算把这个系列写的这么长,但是在写的过程中自己搜了相关的网上资 ...