The kth great number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others) [Problem Description] Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down …
优先队列模拟一下就好. #include<bits/stdc++.h> using namespace std; priority_queue<int>q; int main() { int n; scanf("%d",&n); int t; scanf("%d",&t); ; i <= n; i++){ int v; scanf("%d",&v); q.push(v); } ; while(…
D. Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jzzhu is the president of country A. There are n cities numbered from 1 to n in his country. City 1 is the capital of A.…
贪心策略:每次选取最小的两个数相加,将和作为新的数加入序列,再从里面取两个最小的数...直到只剩下一个数.优先队列正好对付这题. PS :以前在学校OJ做过几乎一毛一样的这题 AC代码: #include<cstdio> #include<queue> using namespace std; priority_queue<int, vector<int>, greater<int> >Q; //the smallest is on top in…