正文
增加 4 行删除 4 行
17 行未改动1819202122232425262728293031323334353637383940414243444517 行未改动int main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> t;while(t--){cin >> n >> k;for(int i=1;i<=n;i++) cin >> a[i];priority_queue<ll,vector<ll>,greater<ll>> pq;for(int i=n;i>=1;i--){pq.push(a[i]);ll cnt=(n-i+1)/(k+1);while(pq.size()>cnt) pq.pop();}ll res=0;while(pq.size()){res+=pq.top();pq.pop();}cout << res << "\n";}return 0;}```17 行未改动1819202122232425262728293031323334353637383940414243444517 行未改动int main(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin >> t;while(t--){cin >> n >> k;for(int i=1;i<=n;i++) cin >> a[i];priority_queue<ll,vector<ll>,greater<ll>> pq;for(int i=n;i>=1;i--){pq.push(a[i]);ll cnt=(n-i+1)/(k+1);while(pq.size()>cnt) pq.pop();}ll res=0;while(pq.size()){res+=pq.top();pq.pop();}cout << res << "\n";}return 0;}```