上分准备 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: Ensure X Window System is not installed
参考 2.2.2 Ensure X Window System is not installed X window System是什么 The X Window System provides a G ...
- BUUCTF-[极客大挑战 2019]Http
一道考察http请求头X-Forwarded-For字段和Referer字段User-Agent字段的题目 一.基础知识 X-Forwarded-For(XFF)又名XFF头 1)概述:X-Forwa ...
- 根据pid定时监控CPU使用率和内存使用率并输出到文件 (windows和linux跨平台可用)
有时服务器运维中,某些程序员的应用发布后完全不管CPU和内存的使用率,只觉得代码能运行就行了,这样给我们运维人员经常造成困扰: 比如我在zabbix平台中就经常监测到凌晨1~3~5点时候突然CPU飙升 ...
- 认识canal
cancl实现数据库之间的实时同步的工具.通过读取mysql的二进制日志binlog,模拟mysql的slave服务器来工作. 参考链接: https://blog.csdn.net/yehongzh ...
- python 查找文件夹下以特定字符开头的某类型文件 - os.walk
Python os.walk() 方法 os.walk() 方法用于通过在目录树中游走输出在目录中的文件名,向上或者向下.os.walk() 方法是一个简单易用的文件.目录遍历器,可以帮助我们高效的处 ...
- GuzzleHttp示例
一般请求 $httpClient = new Client([ 'timeout' => 5 ]); $request = $httpClient->post("http://l ...
- windows 服务 包装模板
github地址: https://github.com/xl711436/Xiaolei.MockService 在 MockServiceInstance.cs 中 对应的方法中添加 对应的逻辑 ...
- js中常用的运算符
1. ?. 链接运算符 特性: 一旦遇到空置就会终止 例子: let name = obj?.name persion.getTip?.() // 没有getTip 方法则不会执行 2. ?? 空值合 ...
- Redis缓存之spring boot 部署
一.环境准备工作 # 1.JDK 安装与环境变量# 下载相应的jdk软件包,然后解压安装,我这里包名称为:jdk-8u102-linux-x64.tar.gz [root@localhost data ...
- 51nod1355
没啥意思的板子题. 首先,众所周知, \[\gcd\{f_a,f_b\}=f_{\gcd\{a,b\}} \] 所以考虑将 \(\operatorname{lcm}\) 转化为 \(\gcd\). \ ...