+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没有匹配完的输出
  1. // AC one more times
  2.  
  3. LL a,s;
  4. std::vector<int > d1,d2;
  5. void chuli()
  6. {
  7. LL ta=a;
  8. while(ta)
  9. {
  10. d1.push_back(ta%10);
  11. ta/=10;
  12. }
  13. ta=s;
  14. while(ta)
  15. {
  16. d2.push_back(ta%10);
  17. ta/=10;
  18. }
  19. }
  20. void solve()
  21. {
  22. d1.clear(),d2.clear();
  23. cin>>a>>s;
  24. if(a>s)
  25. {
  26. cout<<-1<<endl; return;
  27. }
  28. chuli();
  29. int len1=d1.size(),len2=d2.size(),j=0, ca=len2-len1;
  30. vector<int> ans;
  31. for(int i=0;i<len1;i++)
  32. {
  33. int t1=d1[i],t2=d2[j],t3=d2[j+1];
  34. if(ca&&t1+9>=t3*10+t2&&j<len2&&j+1<len2&&t3!=0)
  35. {
  36. int add=t3*10+t2;
  37. ans.push_back(add-t1);
  38. j++,j++;
  39. ca--;
  40. }
  41. else if(t1+(t2-t1)<10&&t2>=t1&&j<len2)
  42. {
  43. int add=t2-t1;
  44. ans.push_back(add);
  45. j++;
  46. }
  47. else if(t1>t2)
  48. {
  49. cout<<-1<<endl; return;
  50. }
  51. }
  52. if(j!=len2)
  53. {
  54. for(int i=len2-1;i>=j;i--)
  55. cout<<d2[i];
  56. reverse(ans.begin(),ans.end());
  57. for(auto it : ans)
  58. cout<<it;
  59. cout<<endl;
  60. }
  61. else
  62. {
  63. int sz=ans.size();
  64. while(ans[sz-1]==0&&sz>=1)
  65. sz--;
  66. if(sz==0)
  67. {
  68. cout<<0<<endl; return;
  69. }
  70. for(int i=sz-1;i>=0;i--)
  71. cout<<ans[i];
  72. cout<<endl;
  73. }
  74.  
  75. return;
  76. }
  77.  
  78. int main()
  79. {
  80. std::ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr);
  81.  
  82. int T;cin>>T;for(int i=1;i<=T;i++)
  83. solve();
  84.  
  85. return 0;
  86. }

E 构造贪心下,

每个最小没出现的整数 d ,答案是:

  1. 更小的数 进行操作,使得 0~d-1 都有数字
  2. 数组内所有=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 了

  1. // AC one more times
  2. void solve()
  3. {
  4. int a[200010],n;
  5. memset(a,0,sizeof a);
  6. cin>>n;
  7. for(int i=1;i<=n;i++)
  8. {
  9. int x; cin>>x;
  10. a[x]++;
  11. }
  12.  
  13. LL chengben=0;
  14. priority_queue<int,vector<int>,less<int>> q;
  15. for(int i=0;i<=n;i++)
  16. {
  17. if(i==0)
  18. {
  19. cout<<a[i]<<" ";
  20. if(a[0]==0)
  21. {
  22. for(int j=1;j<=n;j++)
  23. cout<<-1<<" ";
  24. cout<<endl;return;
  25. }
  26. if(a[i]>1)
  27. for(int j=2;j<=a[i];j++)
  28. q.push(i);
  29. }
  30. if(i>=1)
  31. {
  32. cout<<chengben+a[i]<<" ";
  33. if(a[i]==0)
  34. {
  35. if(q.empty())
  36. {
  37. for(int j=i+1;j<=n;j++)
  38. cout<<-1<<" ";
  39. cout<<endl;return;
  40. }
  41. else
  42. {
  43. chengben+=i-q.top(); q.pop();
  44. }
  45.  
  46. }
  47. if(a[i]>=1)
  48. for(int j=2;j<=a[i];j++)
  49. q.push(i);
  50. }
  51.  
  52. }
  53. cout<<endl;
  54. return;
  55. }
  56.  
  57. int main()
  58. {
  59. std::ios::sync_with_stdio(false); cin.tie(nullptr), cout.tie(nullptr);
  60. int T;cin>>T;for(int i=1;i<=T;i++)
  61. solve();
  62. return 0;
  63. }

上分准备 VP Codeforces Round #762 (Div. 3) 4题ABCE的更多相关文章

  1. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  2. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  3. Codeforces Round #713 (Div. 3)AB题

    Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...

  4. Codeforces Round #833 (Div. 2)补题

    Codeforces Round #833 (Div. 2) D. ConstructOR 知识点:高位和对低位无影响 一开始以为和广州的M一样,是数位dp,后来发现只要找到一个就行 果然无论什么时候 ...

  5. 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 ...

  6. 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 ...

  7. Codeforces Round #367 (Div. 2) 套题

    吐槽:只能说是上分好场,可惜没打,唉 A:Beru-taxi (水题,取最小值) #include <cstdio> #include <cstring> #include & ...

  8. 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 ...

  9. Codeforces Round #762 (Div. 3), CDE

    (C) Wrong Addition Problem - C - Codeforces 题意 定义一种计算方式, 对于a+b=c,  给出a和c, 求b 题解 因为求法是从个位求得, 先求出来的最后输 ...

  10. 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 ...

随机推荐

  1. 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 ...

  2. BUUCTF-[极客大挑战 2019]Http

    一道考察http请求头X-Forwarded-For字段和Referer字段User-Agent字段的题目 一.基础知识 X-Forwarded-For(XFF)又名XFF头 1)概述:X-Forwa ...

  3. 根据pid定时监控CPU使用率和内存使用率并输出到文件 (windows和linux跨平台可用)

    有时服务器运维中,某些程序员的应用发布后完全不管CPU和内存的使用率,只觉得代码能运行就行了,这样给我们运维人员经常造成困扰: 比如我在zabbix平台中就经常监测到凌晨1~3~5点时候突然CPU飙升 ...

  4. 认识canal

    cancl实现数据库之间的实时同步的工具.通过读取mysql的二进制日志binlog,模拟mysql的slave服务器来工作. 参考链接: https://blog.csdn.net/yehongzh ...

  5. python 查找文件夹下以特定字符开头的某类型文件 - os.walk

    Python os.walk() 方法 os.walk() 方法用于通过在目录树中游走输出在目录中的文件名,向上或者向下.os.walk() 方法是一个简单易用的文件.目录遍历器,可以帮助我们高效的处 ...

  6. GuzzleHttp示例

    一般请求 $httpClient = new Client([ 'timeout' => 5 ]); $request = $httpClient->post("http://l ...

  7. windows 服务 包装模板

    github地址:  https://github.com/xl711436/Xiaolei.MockService 在 MockServiceInstance.cs 中 对应的方法中添加 对应的逻辑 ...

  8. js中常用的运算符

    1. ?. 链接运算符 特性: 一旦遇到空置就会终止 例子: let name = obj?.name persion.getTip?.() // 没有getTip 方法则不会执行 2. ?? 空值合 ...

  9. Redis缓存之spring boot 部署

    一.环境准备工作 # 1.JDK 安装与环境变量# 下载相应的jdk软件包,然后解压安装,我这里包名称为:jdk-8u102-linux-x64.tar.gz [root@localhost data ...

  10. 51nod1355

    没啥意思的板子题. 首先,众所周知, \[\gcd\{f_a,f_b\}=f_{\gcd\{a,b\}} \] 所以考虑将 \(\operatorname{lcm}\) 转化为 \(\gcd\). \ ...