http://codeforces.com/gym/100623/attachments H题
http://codeforces.com/gym/100623/attachments H题
已经给出来的,包括后来添加的,都累加得到ans,那么从1~ans都是可以凑出来的,如果ans<a[now]-1,那么就添加一个ans+1,然后继续操作。
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 100010
#define For(i,a,b) for(long long i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std; long long n,m;
long long a[],b[];
long long ans,cnt,now;
bool flag;
void in(long long &x){
long long y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(long long x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
}
int main(){
freopen("key.in","r",stdin);
freopen("key.out","w",stdout);
in(n);in(m);
For(i,,n)
in(a[i]);
sort(a+,a+n+);
if(a[]!=){
b[++cnt]=;
ans++;
m--;
}
// if(m>0)
// For(i,1,n-1){
// ans+=a[i];
// if(ans<a[i+1]-1){
// b[++cnt]=ans+1;
// ans+=ans+1;
// m--;
// }
// if(!m)
// break;
// }
now=;
while(m>){
if(ans<a[now]-){
b[++cnt]=ans+;
ans+=ans+;
m--;
}
else{
ans+=a[now];
now++;
}
if(now>n)
break;
}
while(m>){
b[++cnt]=ans+;
ans+=ans+;
m--;
}
For(i,,cnt)
o(b[i]),p(' ');
return ;
}
http://codeforces.com/gym/100623/attachments H题的更多相关文章
- http://codeforces.com/gym/100623/attachments E题
http://codeforces.com/gym/100623/attachments E题第一个优化它虽然是镜像对称,但它毕竟是一一对称的,所以可以匹配串和模式串都从头到尾颠倒一下第二个优化,与次 ...
- Codeforces Gym 100342H Problem H. Hard Test 构造题,卡迪杰斯特拉
Problem H. Hard TestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/at ...
- Codeforces Gym 100531G Grave 水题
Problem G. Grave 题目连接: http://codeforces.com/gym/100531/attachments Description Gerard develops a Ha ...
- Gym 100531H Problem H. Hiking in the Hills 二分
Problem H. Hiking in the Hills 题目连接: http://codeforces.com/gym/100531/attachments Description Helen ...
- 2018icpc 徐州h题
题目大意: https://codeforces.com/gym/102012/problem/H?csrf_token=c9d0191a64a241166d54a565b1615125 区间[l , ...
- Codeforces Gym 100610 Problem H. Horrible Truth 瞎搞
Problem H. Horrible Truth Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/1006 ...
- Codeforces Round #378 (Div. 2) D题(data structure)解题报告
题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...
- Codeforces 828B Black Square(简单题)
Codeforces 828B Black Square(简单题) Description Polycarp has a checkered sheet of paper of size n × m. ...
- 【codeforces.com/gym/100240 J】
http://codeforces.com/gym/100240 J [分析] 这题我搞了好久才搞出样例的11.76....[期望没学好 然后好不容易弄成分数形式.然后我‘+’没打..[于是爆0... ...
随机推荐
- WPF DataGridTextColum 显示时间格式化
<DataGrid Name="DGVisit" Grid.Row="2" AutoGenerateColumns="False" C ...
- iOS开发系列-NSOutputStream
NSOutputStream 创建一个NSOutputStream实例 - (nullable instancetype)initToFileAtPath:(NSString *)path appen ...
- Lotus Blossom 行动分析
1 漏洞介绍 1.1 代号 - Lotus Blossom行动 漏洞利用率很高 从2012 -2015或者说最近都还在使用 CVE-2012-0158 Lotus Blossom--莲花: 描述了对东 ...
- 警告(alert 消息对话框) 如果你不点击“确定”,就不能对网页做任何操作,这个小窗口就是使用alert实现的
警告(alert 消息对话框) 我们在访问网站的时候,有时会突然弹出一个小窗口,上面写着一段提示信息文字.如果你不点击"确定",就不能对网页做任何操作,这个小窗口就是使用alert ...
- react中使用屏保
1,默认路由路径为屏保组件 <HashRouter history={hashHistory}> <Switch> <Route exact path="/&q ...
- AM8 自定义表情包的实现方法
AM8 自定义表情包的实现方法 效果描述 AM8 安装后,在\Activesoft\AMm8\emotions 目录内存储的是默认的表情符号.但有的时候我们需要增加一些新的表情符号,AM8 系统支持自 ...
- 2-sat——poj3678经典建图
比较经典的建图,详见进阶指南 2-sat一般要用到tarjan来求强连通分量 /*2-sat要加的是具有强制关系的边*/ #include<iostream> #include<cs ...
- 图书-技术-SpringBoot:《Spring Boot 企业级应用开发实战》
ylbtech-图书-技术-SpringBoot:<Spring Boot 企业级应用开发实战> Spring Boot 企业级应用开发实战,全书围绕如何整合以 Spring Boot 为 ...
- diskpart
比如格式化成fat32 format fs=fat32 quick 比鼠标方便 如何使用: 打开cmd输入diskpart进入命令 首先 list disk 然后 然后 clean 然后 create ...
- 利用refind实现UEFI多系统引导
使用DiskGenius Pro给ESP分区指定盘符,目的是为了让ESP分区在硬盘上可见 使用BOOTICE工具中的UEFI选项卡中的功能调整引导顺序 修改启动序列-->EFI NetWork- ...