Submission #75249896


Source Code Expand

#include <bits/stdc++.h>
#include <atcoder/all>

#define LF putchar('\n')

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 998244353LL; //1000000007LL;
static const LLONG INF_NUM = 1e18;
static const int CH_KIND = 'z' - 'a' + 1;
template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}
template <class _T> static _T tp_pow(int x, int exp)
{
	_T ans = 1;
	_T base = x;
	while (exp > 0) {
		if (exp & 1) {
			ans = (ans * base);
		}
		base = (base * base);
		exp >>= 1;
	}
	return ans;
}

static void task();

int main()
{
	task();
	fflush(stdout);
	return 0;
}

static void task()
{
    int N, K;
    get(N, K);

    std::map<LLONG, LLONG> sums;
    for (int i = 0; i < N; i++) {
        LLONG n;
        get(n);

        sums[n] += n;
    }
    std::vector<LLONG> vals;
    for (auto p : sums) {
        vals.push_back(p.second);
    }
    std::sort(vals.begin(), vals.end(), std::greater<LLONG>());

    for (int i = 0; i < std::min(K, (int)vals.size()); i++) {
        vals[i] = 0;
    }
    LLONG ans = 0;
    for (auto v : vals) ans+= v;
    printf("%lld\n", ans);
}

Submission Info

Submission Time
Task C - Vanish
User takumat
Language C++23 (GCC 15.2.0)
Score 300
Code Size 1446 Byte
Status AC
Exec Time 229 ms
Memory 26400 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 31
Set Name Test Cases
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt
Case Name Status Exec Time Memory
sample00.txt AC 1 ms 3652 KiB
sample01.txt AC 1 ms 3780 KiB
sample02.txt AC 1 ms 3796 KiB
testcase00.txt AC 1 ms 3768 KiB
testcase01.txt AC 1 ms 3652 KiB
testcase02.txt AC 183 ms 21844 KiB
testcase03.txt AC 216 ms 26400 KiB
testcase04.txt AC 141 ms 18752 KiB
testcase05.txt AC 219 ms 26340 KiB
testcase06.txt AC 82 ms 12784 KiB
testcase07.txt AC 229 ms 26348 KiB
testcase08.txt AC 18 ms 3764 KiB
testcase09.txt AC 80 ms 3780 KiB
testcase10.txt AC 19 ms 3652 KiB
testcase11.txt AC 82 ms 3764 KiB
testcase12.txt AC 40 ms 3764 KiB
testcase13.txt AC 88 ms 3768 KiB
testcase14.txt AC 89 ms 3976 KiB
testcase15.txt AC 93 ms 3780 KiB
testcase16.txt AC 140 ms 9568 KiB
testcase17.txt AC 164 ms 10780 KiB
testcase18.txt AC 14 ms 3780 KiB
testcase19.txt AC 90 ms 3768 KiB
testcase20.txt AC 129 ms 7560 KiB
testcase21.txt AC 165 ms 11252 KiB
testcase22.txt AC 86 ms 3648 KiB
testcase23.txt AC 219 ms 26332 KiB
testcase24.txt AC 164 ms 11036 KiB
testcase25.txt AC 61 ms 3772 KiB
testcase26.txt AC 73 ms 3904 KiB
testcase27.txt AC 73 ms 4044 KiB