Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:注意了用sort不一定能过In Reply To:注意了用sort不一定能过 Posted by:1314199210 at 2013-07-31 16:44:06 > 用C++STL sort()排序不一定能过,我已经试了,原因不明, 水过啊 #include <algorithm> #include <iostream> #include <string> #include <queue> #include <cstring> #include <cstdlib> #include <cstdio> #include <cmath> #define N 50010 using namespace std; struct cows { int i, a, b; } c[N]; bool cmp1(cows a, cows b) { return a.a > b.a; } bool cmp2(cows a, cows b) { return a.b > b.b; } int main() { int n, k, a, b; int i; scanf("%d %d", &n, &k); for(i=0; i<n; ++i) { scanf("%d %d", &a, &b); c[i].i = i + 1; c[i].a = a; c[i].b = b; } sort(c, c+n, cmp1); sort(c, c+k, cmp2); printf("%d\n", c[0].i); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator