acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(4)讨论(0)提交记录(359)
  • 【正经题解】歌曲压缩

    userId_undefined

    AC君

    小有名气倔强青铜管理员
    21阅读
    0回复
    0点赞
  • 题解

    userId_undefined

    法兰西玫瑰

    11阅读
    0回复
    0点赞
  • 吴

    #include<bits/stdc++.h> using namespace std; // 音乐结构体 struct Music { int originalSize; // 初始大小 int compressedSize; // 压缩后大小 }; // 用于 priority_queue 的比较函数 struct Compare { bool operator()(const Music& m1, const Music& m2) const { return (m1.originalSize - m1.compressedSize) < (m2.originalSize - m2.compressedSize); } }; int main() { priority_queue<Music, vector<Music>, Compare> pq; // 使用自定义比较函数的优先队列 int numSongs, flashDriveCapacity; cin >> numSongs >> flashDriveCapacity; } //吴吴吴

    userId_undefined

    小吴

    3阅读
    0回复
    0点赞
  • 20

    #include<iostream> #include<vector> #include<string> #include<set> #include<queue> #include<algorithm> using namespace std; struct SS { long a; //原大小 long b; //压缩后 } q[100005]; bool cmp(struct SS p1, struct SS p2) { if (p1.a > p2.a) return true; if (p1.a == p2.a && p1.b <= p2.b) return true; return false; } int main() { priority_queue<int> que; //默认为大顶堆 long n, m, sum = 0, cnt = 0; cin >> n >> m; //歌曲数 硬盘大小 for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; sum += x; que.push(x - y); q[i].a = x, q[i].b = y; } //sort(q,q+n,cmp); }

    userId_undefined

    我

    贪心·贪心尝试者枚举·枚举小能手秩序白银
    1阅读
    0回复
    0点赞
首页