蒟蒻求助!!!就差一点就AC
  • 板块题目总版
  • 楼主小吴2011
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/8/14 23:22
  • 上次更新2024/8/15 09:45:41
查看原帖
蒟蒻求助!!!就差一点就AC
1358629
小吴2011楼主2024/8/14 23:22

因为这是我在别的网站写的,洛谷也没找到,于是我的题目链接放在这里 题目

我已经做了N遍了,真的哭死〒▽〒

#include<bits/stdc++.h>  
using namespace std;  
struct P {  
    int id;  
    int fs;  
} a[3005];  
bool cmp(P x, P y) {  
    if (x.fs == y.fs)  
        return x.id < y.id;  
    return x.fs > y.fs;
}  
int main() {  
    int n, k;  
    cin >> n >> k;  
    for (int i = 1; i <= n; i++) {  
        cin >> a[i].fs;  
        a[i].id = i;  
    }  
    sort(a+1,a+n+1,cmp);  
    int cnt = 0;  
    for (int i=k+1; i<=n;i++) {  
        if (a[i].fs == a[k].fs) {  
            cnt++;  
        }  
    }  
    cout << cnt;  
    return 0;  
}
2024/8/14 23:22
加载中...