上分准备 VP Codeforces Round #762 (Div. 3) 4题ABCE
| +00:02 | +00:16 | +01:08 | +02:07 |
VP 情况 4/8 ABCE ,赛时排名可以到823,什么时候我可以上个青
- B 本想写个map的二分的,发现自己不会,写了个普普通通的二分
- C 高精度模拟,一发过了,用个vector将每个数位存起来,从个位开始判断,如果 A_i 的数能加上小于10的正整数大于等于S_j+1 *10 + S_j,(S_j+1 ! = 0),那么就能一次解决两个数位,其余正常匹配,遇到无法进位同时 A_i > S_j 的情况就没有解 ,最后讨论前导0,和S没有匹配完的输出
// AC one more times LL a,s;
std::vector<int > d1,d2;
void chuli()
{
LL ta=a;
while(ta)
{
d1.push_back(ta%10);
ta/=10;
}
ta=s;
while(ta)
{
d2.push_back(ta%10);
ta/=10;
}
}
void solve()
{
d1.clear(),d2.clear();
cin>>a>>s;
if(a>s)
{
cout<<-1<<endl; return;
}
chuli();
int len1=d1.size(),len2=d2.size(),j=0, ca=len2-len1;
vector<int> ans;
for(int i=0;i<len1;i++)
{
int t1=d1[i],t2=d2[j],t3=d2[j+1];
if(ca&&t1+9>=t3*10+t2&&j<len2&&j+1<len2&&t3!=0)
{
int add=t3*10+t2;
ans.push_back(add-t1);
j++,j++;
ca--;
}
else if(t1+(t2-t1)<10&&t2>=t1&&j<len2)
{
int add=t2-t1;
ans.push_back(add);
j++;
}
else if(t1>t2)
{
cout<<-1<<endl; return;
}
}
if(j!=len2)
{
for(int i=len2-1;i>=j;i--)
cout<<d2[i];
reverse(ans.begin(),ans.end());
for(auto it : ans)
cout<<it;
cout<<endl;
}
else
{
int sz=ans.size();
while(ans[sz-1]==0&&sz>=1)
sz--;
if(sz==0)
{
cout<<0<<endl; return;
}
for(int i=sz-1;i>=0;i--)
cout<<ans[i];
cout<<endl;
} return;
} int main()
{
std::ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr); int T;cin>>T;for(int i=1;i<=T;i++)
solve(); return 0;
}
E 构造贪心下,
每个最小没出现的整数 d ,答案是:
- 更小的数 进行操作,使得 0~d-1 都有数字
- 数组内所有=d的数 进行+1
用一个数组标记值为i的数有多少个
如何使得进行操作数最少? 如果到了数 i ,这个地方标记数为0,那么就要比他小的数加1,我们用更小的数进行操作使它达到i,使得 MEX= ii+1 时候成立,这里用一个优先队列来维护可以进行操作的数,使得每次操作数最小。当a[i] >=2 ,就将a[i]-1个 i 加入优先队列。也用一个 chengben来记录补上 0~i-1 的坑(原本a[0~i-1] = 0 处),当MEX=i,答案为chengben + a[i] ,如果前面有坑没补上,后面就全输出-1 了
// AC one more times
void solve()
{
int a[200010],n;
memset(a,0,sizeof a);
cin>>n;
for(int i=1;i<=n;i++)
{
int x; cin>>x;
a[x]++;
} LL chengben=0;
priority_queue<int,vector<int>,less<int>> q;
for(int i=0;i<=n;i++)
{
if(i==0)
{
cout<<a[i]<<" ";
if(a[0]==0)
{
for(int j=1;j<=n;j++)
cout<<-1<<" ";
cout<<endl;return;
}
if(a[i]>1)
for(int j=2;j<=a[i];j++)
q.push(i);
}
if(i>=1)
{
cout<<chengben+a[i]<<" ";
if(a[i]==0)
{
if(q.empty())
{
for(int j=i+1;j<=n;j++)
cout<<-1<<" ";
cout<<endl;return;
}
else
{
chengben+=i-q.top(); q.pop();
} }
if(a[i]>=1)
for(int j=2;j<=a[i];j++)
q.push(i);
} }
cout<<endl;
return;
} int main()
{
std::ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr);
int T;cin>>T;for(int i=1;i<=T;i++)
solve();
return 0;
}
上分准备 VP Codeforces Round #762 (Div. 3) 4题ABCE的更多相关文章
- Codeforces Round #612 (Div. 2) 前四题题解
这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...
- Codeforces Round #378 (Div. 2) D题(data structure)解题报告
题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...
- Codeforces Round #713 (Div. 3)AB题
Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...
- Codeforces Round #833 (Div. 2)补题
Codeforces Round #833 (Div. 2) D. ConstructOR 知识点:高位和对低位无影响 一开始以为和广州的M一样,是数位dp,后来发现只要找到一个就行 果然无论什么时候 ...
- Codeforces Round #552 (Div. 3) A题
题目网址:http://codeforces.com/contest/1154/problem/ 题目意思:就是给你四个数,这四个数是a+b,a+c,b+c,a+b+c,次序未知要反求出a,b,c,d ...
- Codeforces Round #412 Div. 2 补题 D. Dynamic Problem Scoring
D. Dynamic Problem Scoring time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #367 (Div. 2) 套题
吐槽:只能说是上分好场,可惜没打,唉 A:Beru-taxi (水题,取最小值) #include <cstdio> #include <cstring> #include & ...
- Codeforces Round #587 (Div. 3) C题 【判断两个矩形是否完全覆盖一个矩形问题】 {补题 [差点上分系列]}
C. White Sheet There is a white sheet of paper lying on a rectangle table. The sheet is a rectangle ...
- Codeforces Round #762 (Div. 3), CDE
(C) Wrong Addition Problem - C - Codeforces 题意 定义一种计算方式, 对于a+b=c, 给出a和c, 求b 题解 因为求法是从个位求得, 先求出来的最后输 ...
- Codeforces Round #376 (Div. 2) C题 Socks(dsu+graphs+greedy)
Socks Problem Description: Arseniy is already grown-up and independent. His mother decided to leave ...
随机推荐
- 2017GPLT
PTA天梯赛2017GPLT 7-6 整除光棍 给定一个不以5结尾的奇数\(x\),求出数字\(n\)使得\(n*x=11...111\),输出数字n和1的位数 题解:模拟竖式除法 我们一开始发现n只 ...
- 调度器46—tick模式
一.tick简介 tick就是一个周期性的中断,周期通过 CONFIG_HZ 进行配置,一般常取值为100Hz.250Hz.1000Hz.Tick 每秒窃取CPU 100 到 1000 次,导致Ica ...
- 【服务器数据恢复】RAID6数据恢复案例
服务器数据恢复环境:一台Web服务器中有一组由8块磁盘组建的raid6磁盘阵列,用来运行数据库和存储普通办公文件. 服务器故障:服务器raid6磁盘阵列中有两块硬盘离线,但是管理员没有注意到这种情况, ...
- ubuntu 下如何设置环境变量
一.设置环境变量的三种方法 1.1 临时设置 export PATH=/home/yan/share/usr/local/arm/3.4.1/bin:$PATH 1.2 当前用户的全局设置 打开~/. ...
- Enhancement S_ALR_87011964 Asset Balance Report to add custom column
Enhancement S_ALR_87011964 Asset Balance Report to add custom column - SAP Tutorial Include own fiel ...
- vscode 右键运行php文件到浏览器
1.安装PHP Server插件 2.在需要打开的文件中右键选择PHP Server:Server project 3.浏览器页面显示
- centos7.6安装rz命令上传文件
centos7.6安装rz命令 1.执行安装命令:yum -y install lrzsz 2.进行上传操作:rz 跳转到本地文件选择后即可上传
- 线上服务Java进程假死快速排查、分析
引用 https://zhuanlan.zhihu.com/p/529350757 最近我们有一台服务器上的Java进程总是在运行个两三天后就无法响应请求了,具体现象如下: 请求业务返回状态码502, ...
- Kubernetes学习笔记(一)
参考: kubectl Cheat Sheet | Kubernetes Kubernetes kubectl 命令表 _ Kubernetes(K8S)中文文档_Kubernetes中文社区 Pla ...
- Anaconda配置环境变量
环境变量里写自己的Anaconda下载目录,找到对应的文件位置,然后把这三个上移到最上面,点击确定即可配置完成 出现这个环境变量就成功啦 在输入conda 出现这个就表明你的Anaconda已经好了