用桶排序却只过了样例 急急急

P1090 [NOIP2004 提高组] 合并果子 / [USACO06NOV] Fence Repair G

您可否听说过一种东西叫STL,STL中有一种东西叫priority_queue(优先队列容器)?根本不需要桶排序。 本题应用priority_queue的样例代码: ```cpp #include <iostream> #include <cmath> #include <algorithm> #include <string> #include <queue> using namespace std; class this_is_main { priority_queue<int,vector<int>,greater<int>>a; int b,c,d=0,e; public: this_is_main() { cin >> b; for (int i = 0; i < b; i++) { cin >> c; a.push(c); } while (a.size() > 1) { e = 0; e += a.top(); a.pop(); e += a.top(); a.pop(); a.push(e); d += e; } cout << d; } }; this_is_main run_main; int main() { return 0; } ```
by GodForever @ 2023-01-01 16:05:27


|