Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

 
 
 
 
General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
208181362 Practice:
computerbigboom
1832B - 13 C++20 (GCC 11-64) Wrong answer on test 3 373 ms 0 KB 2023-06-02 18:01:48 2023-06-02 18:01:48
→ Source
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;

int main(){
    lli t, n, k;
    vector<lli> a;
    lli temp;
    lli ans;
    cin >> t;
    lli ptr_2_min, ptr_max;
    bool flag;
    for (lli i = 0; i < t; ++i){
        cin >> n >> k;
        a.clear();
        for (lli j = 0; j < n; ++j){
            cin >> temp;
            a.push_back(temp);
        }
        sort(a.begin(), a.end());
        ptr_2_min = 0;
        ptr_max = n-k;
        flag = true;
        while (flag && ptr_max < n){
            if (a[ptr_2_min] + a[ptr_2_min+1] < a[ptr_max]){
                ptr_2_min += 2;
                ++ptr_max;
            }
            else {
                flag = false;
            }
        }
        ans = 0;
        for (lli j = ptr_2_min; j < ptr_max; ++j){
            ans += a[j];
        }
        cout << ans << endl;
    }
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details