复习 排序

发布时间 2024-01-04 16:25:47作者: .Ivorelectra

POJ 3664 排序水题

#include <cstdio>
#include <vector>
#include <queue>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int>P;
const int maxn = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const ll mod = 998244353;
const double eps = 1e-11;
const double pi = 3.141592653;

int n, k;
struct node
{
    int a, b, id;
}cow[50010];

bool cmp1(const node& x, const node& y)
{
    return x.a > y.a;
}

bool cmp2(const node& x, const node& y)
{
    return x.b > y.b;
}

int main()
{
    cin >> n >> k;
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d %d", &cow[i].a, &cow[i].b);
        cow[i].id = i;
    }
    sort(cow + 1, cow + 1 + n, cmp1);
    sort(cow + 1, cow + 1 + k, cmp2);
    cout << cow[1].id << endl;
}