Chủ Nhật, 3 tháng 4, 2022

TAMBIA C++


#include<bits/stdc++.h>
using namespace std;
#define ll long long


int x,n , m , k;
int d[100005];

void nhap()
{
    cin >> m >> n >> k;
    for(int i=1;i<=m;i++)
        for(int j=1;j<=n;j++)
    {
        cin >> x;
        d[x]++;
    }
}

bool ss(int x, int y)
{
    return x > y;
}

void xuli()
{
    sort(d+1, d+100000+1, ss);
    ll ans = 0;
    for(int i=1;i<=k;i++) ans += d[i];
        cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("tambia.inp","r",stdin);
    freopen("tambia.out","w",stdout);

        nhap();
        xuli();
}


Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.