题意是有 n 个人要对 m 件服装打分,按总分从高到低排序,再将总分排在前 k 名的服装按编号的从高到低输出,结构体排序. 代码如下: #include <bits/stdc++.h> using namespace std; struct shirt { int num; double price; }t[]; bool cmp1(shirt a,shirt b) { return a.price>b.price; } bool cmp2(shirt a,shirt b) { retu…
http://acm.hdu.edu.cn/showproblem.php?pid=1031 题意 :n个人,每个人对m件衣服打分,每个人对第 i 件衣服的打分要加起来,选取和前 k 高的输出他们的编号 i ,然后这k个的序号要倒序输出 思路 :快排一下就行了.这道题坑了我好几遍TLE,原因是我交的语言是G++而不是C++...... #include <iostream> #include <algorithm> #include <stdio.h> using na…
partial sort. first use std::nth_element to find pivot, then use std::stable_partition with the pivot to partition the largest k, whose indices are in acsending order, print them in reverse order. p.s. lambda expression is also used. STL is powerful.…
Design T-Shirt Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6527 Accepted Submission(s): 3061 Problem Description Soon after he decided to design a T-shirt for our Algorithm Board on Free…
Design T-Shirt Problem Description Soon after he decided to design a T-shirt for our Algorithm Board on Free-City BBS, XKA found that he was trapped by all kinds of suggestions from everyone on the board. It is indeed a mission-impossible to have eve…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2426 For any school, it is hard to find a feasible accommodation plan with every student assigned to a suitable apartment while keeping everyone happy, let alone an optimal one. Recently the president of…