上分准备 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 ...
随机推荐
- 查找大文件-清理linux磁盘
https://www.cnblogs.com/kerrycode/p/4391859.html find . -type f -size +800M -print0 | xargs -0 du - ...
- 查找数组中某个元素出现的次数,例如数组arr=[1,2,3,4,3,4,5,3]中target=3出现的次数
1 function(arr,target) { 2 3 let num = 0 4 5 arr.forEach((item, index) => { 6 7 if (item===target ...
- python读取xml格式数据
读取节点文本值和,属性值 # -*- coding: UTF-8 -*- from xml.dom import minidom dom=minidom.parse('F:\\python_proje ...
- 蓝桥杯训练赛二-问题 B
字符串的输入输出处理. 输入 第一行是一个正整数N,最大为100.之后是多行字符串(行数大于N), 每一行字符串可能含有空格,字符数不超过1000. 输出 先将输入中的前N行字符串(可能含有空格)原样 ...
- R7-3 汉诺(Hanoi)塔问题
R7-3 汉诺(Hanoi)塔问题 分数 20 全屏浏览题目 切换布局 作者 张高燕 单位 浙大城市学院 古代某寺庙中有一个梵塔,塔内有3个座A.B和C,座A上放着64个大小不等的盘,其中大盘在下,小 ...
- java 动手动脑 方法重载
如下代码://MethodOverload.java //Using overloaded methods package HJssss; public class zhuce { public st ...
- spring注解SQL注意事项
目前有两个类:机构.职员 package com.common.vo; public class Org{ public long id; public String name; public Str ...
- vue中,解决chrome下,的warning, Added non-passive event listener to a scroll-blocking ‘mousewheel‘ event 问题
写项目的时候,Chrome 提醒: [Violation] Added non-passive event listener to a scroll-blocking 'mousewheel' eve ...
- Java基础——方法
package com.zhao.demo; public class Demo07 { /* public static void main(String[] args) { //getSum(10 ...
- ATM+购物车导图
1 #项目需求: 1.额度15000或者自定义 ---> 注册功能 2.实现购物商城,买东西假如购物车,调用信用卡接口结账 ---> 购物功能.支付功能 3.可以提现,手续费5% ---- ...