Submission #75248904


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
int n,k;
long long s,sum,a[300005];
vector<long long> v;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){
		if(a[i]==a[i-1]) s+=a[i];
		else if(i>1) v.push_back(s),s=a[i];
		else s=a[i];
	}
	v.push_back(s),s=0,sort(v.begin(),v.end());
	for(int i=0;i+k<v.size();i++) s+=v[i];
	cout<<s;
}

Submission Info

Submission Time
Task C - Vanish
User Rya_
Language C++23 (GCC 15.2.0)
Score 300
Code Size 399 Byte
Status AC
Exec Time 102 ms
Memory 9928 KiB

Compile Error

./Main.cpp: In function 'int main()':
./Main.cpp:16:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(int i=0;i+k<v.size();i++) s+=v[i];
      |                     ~~~^~~~~~~~~

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 3360 KiB
sample01.txt AC 1 ms 3552 KiB
sample02.txt AC 1 ms 3552 KiB
testcase00.txt AC 1 ms 3380 KiB
testcase01.txt AC 1 ms 3428 KiB
testcase02.txt AC 85 ms 7608 KiB
testcase03.txt AC 101 ms 9928 KiB
testcase04.txt AC 69 ms 7212 KiB
testcase05.txt AC 102 ms 9872 KiB
testcase06.txt AC 40 ms 5448 KiB
testcase07.txt AC 102 ms 9884 KiB
testcase08.txt AC 16 ms 4104 KiB
testcase09.txt AC 74 ms 5796 KiB
testcase10.txt AC 17 ms 4100 KiB
testcase11.txt AC 75 ms 6084 KiB
testcase12.txt AC 37 ms 4496 KiB
testcase13.txt AC 79 ms 5956 KiB
testcase14.txt AC 78 ms 5908 KiB
testcase15.txt AC 82 ms 5984 KiB
testcase16.txt AC 82 ms 6592 KiB
testcase17.txt AC 94 ms 6812 KiB
testcase18.txt AC 13 ms 3964 KiB
testcase19.txt AC 81 ms 5868 KiB
testcase20.txt AC 82 ms 6064 KiB
testcase21.txt AC 95 ms 6808 KiB
testcase22.txt AC 79 ms 5984 KiB
testcase23.txt AC 93 ms 9880 KiB
testcase24.txt AC 94 ms 6804 KiB
testcase25.txt AC 57 ms 5796 KiB
testcase26.txt AC 65 ms 5984 KiB
testcase27.txt AC 64 ms 6012 KiB