码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 家庭房产(PTA)


    1. #include <iostream>
    2. #include <vector>
    3. #include <set>
    4. #include <algorithm>
    5. using namespace std;
    6. //10
    7. //6666 5551 5552 1 7777 1 100
    8. //1234 5678 9012 1 0002 2 300
    9. //8888 - 1 - 1 0 1 1000
    10. //2468 0001 0004 1 2222 1 500
    11. //7777 6666 - 1 0 2 300
    12. //3721 - 1 - 1 1 2333 2 150
    13. //9012 - 1 - 1 3 1236 1235 1234 1 100
    14. //1235 5678 9012 0 1 50
    15. //2222 1236 2468 2 6661 6662 1 300
    16. //2333 - 1 3721 3 6661 6662 6663 1 100
    17. set<int> s[1000];
    18. double arr1[1000] = { 0 };
    19. double arr2[1000] = { 0 };
    20. int main() {
    21. int N;
    22. cin >> N;
    23. for (int i = 0; i < N; i++) {
    24. int a;
    25. for (int j = 0; j < 3; j++) {
    26. cin >> a;
    27. if (a != -1) s[i].insert(a);
    28. }
    29. cin >> a;
    30. for (int j = 0, b; j < a; j++) {
    31. cin >> b;
    32. s[i].insert(b);
    33. }
    34. cin >> arr1[i] >> arr2[i];
    35. set<int> r;
    36. for (auto x : s[i]) {
    37. for (int k = 0; k <= i; k++) {
    38. if (s[k].count(x)) {
    39. r.insert(k);
    40. }
    41. }
    42. }
    43. int t = *r.begin();
    44. r.erase(r.begin());
    45. if (r.size()) {
    46. for (auto l : r) {
    47. for (auto p : s[l]) {
    48. s[t].insert(p);
    49. }
    50. arr1[t] += arr1[l];
    51. arr2[t] += arr2[l];
    52. s[l].clear();
    53. }
    54. }
    55. }
    56. //创建一个下标数组,用它排序
    57. vector<int> ind;
    58. for (int i = 0; i < N; i++) {
    59. if (!s[i].empty()) {
    60. ind.push_back(i);
    61. arr1[i] /= s[i].size();
    62. arr2[i] /= s[i].size();
    63. }
    64. }
    65. sort(ind.begin(), ind.end(), [&](int i, int j) -> bool {
    66. if (arr2[i] != arr2[j]) return arr2[i] > arr2[j];
    67. return (*s[i].begin()) < (*s[j].begin());
    68. });
    69. cout << ind.size() << endl;
    70. for (int i = 0, I = ind.size(); i < I; i++) {
    71. printf("%04d %zd %.3lf %.3lf\n", *s[ind[i]].begin(), s[ind[i]].size(),
    72. arr1[ind[i]], arr2[ind[i]]);
    73. }
    74. return 0;
    75. }

  • 相关阅读:
    SpringMvc之Json&全局异常处理
    Hadoop3教程(十六):MapReduce中的OutputFormat
    Codeforces Round 886 (Div. 4)F. We Were Both Children(调和级数、埃氏筛)
    计算机操作系统 第五章 虚拟存储器(1)
    gsteamer日志输出实例
    单商户商城系统功能拆解04—店铺商品分类编辑
    P4447 [AHOI2018初中组]分组——贪心
    C# [字节数组]与[16进制字符串]互相转换 - CodePlus系列
    Vue组件框架(ElementUI+Axios+Vuex)
    【USRP】产品型号、参数、架构全解析系列 9:X410
  • 原文地址:https://blog.csdn.net/Mz_yuner/article/details/133798342
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号