#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n, k, l;
cin >> n >> k >> l;
int m = n*k;
vector<int> g(1,0);
int tmp;
for (int i = 1; i <= m; i++){
cin >> tmp;
g.push_back(tmp);
}
sort(g.begin(), g.end());
if (g[n] - g[1]>l) { cout << 0; return 0; }
int posMaxVol;
const int maxvol = g[1] + l; //max volumn
vector<int>::iterator it;
if (find(g.begin(), g.end(), maxvol ) != g.end()) {
it = upper_bound(g.begin(), g.end(), maxvol);
posMaxVol = it - g.begin() - 1;
}
else{
it = lower_bound(g.begin(), g.end(), maxvol);
posMaxVol = it - g.begin();
}
int cntDu = m - posMaxVol;
long long ans = 0;
while (cntDu>0){
cntDu -= (k - 1);
ans += g[posMaxVol];
posMaxVol--;
}
for (int i = 1; i <= posMaxVol; i += k){
ans += g[i];
}
cout << ans;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkKewoJaW50IG4sIGssIGw7CgljaW4gPj4gbiA+PiBrID4+IGw7CglpbnQgbSA9IG4qazsKCXZlY3RvcjxpbnQ+IGcoMSwwKTsKCWludCB0bXA7Cglmb3IgKGludCBpID0gMTsgaSA8PSBtOyBpKyspewoJCWNpbiA+PiB0bXA7CgkJZy5wdXNoX2JhY2sodG1wKTsKCX0KCXNvcnQoZy5iZWdpbigpLCBnLmVuZCgpKTsKCWlmIChnW25dIC0gZ1sxXT5sKSB7IGNvdXQgPDwgMDsgcmV0dXJuIDA7IH0KCWludCBwb3NNYXhWb2w7Cgljb25zdCBpbnQgbWF4dm9sID0gZ1sxXSArIGw7ICAvL21heCB2b2x1bW4KCgl2ZWN0b3I8aW50Pjo6aXRlcmF0b3IgaXQ7CglpZiAoZmluZChnLmJlZ2luKCksIGcuZW5kKCksIG1heHZvbCApICE9IGcuZW5kKCkpIHsKCQlpdCA9IHVwcGVyX2JvdW5kKGcuYmVnaW4oKSwgZy5lbmQoKSwgbWF4dm9sKTsKCQlwb3NNYXhWb2wgPSBpdCAtIGcuYmVnaW4oKSAtIDE7Cgl9CgllbHNlewoJCWl0ID0gbG93ZXJfYm91bmQoZy5iZWdpbigpLCBnLmVuZCgpLCBtYXh2b2wpOwoJCXBvc01heFZvbCA9IGl0IC0gZy5iZWdpbigpOwoJfQoKCWludCBjbnREdSA9IG0gLSBwb3NNYXhWb2w7Cglsb25nIGxvbmcgYW5zID0gMDsKCXdoaWxlIChjbnREdT4wKXsKCQljbnREdSAtPSAoayAtIDEpOwoJCWFucyArPSBnW3Bvc01heFZvbF07CgkJcG9zTWF4Vm9sLS07Cgl9Cglmb3IgKGludCBpID0gMTsgaSA8PSBwb3NNYXhWb2w7IGkgKz0gayl7CgkJYW5zICs9IGdbaV07Cgl9Cgljb3V0IDw8IGFuczsKCglyZXR1cm4gMDsKfQo=
Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:1: error: class, interface, or enum expected
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <vector>
^
Main.java:3: error: illegal character: '#'
#include <algorithm>
^
Main.java:7: error: class, interface, or enum expected
int main()
^
Main.java:10: error: class, interface, or enum expected
cin >> n >> k >> l;
^
Main.java:11: error: class, interface, or enum expected
int m = n*k;
^
Main.java:12: error: class, interface, or enum expected
vector<int> g(1,0);
^
Main.java:13: error: class, interface, or enum expected
int tmp;
^
Main.java:14: error: class, interface, or enum expected
for (int i = 1; i <= m; i++){
^
Main.java:14: error: class, interface, or enum expected
for (int i = 1; i <= m; i++){
^
Main.java:14: error: class, interface, or enum expected
for (int i = 1; i <= m; i++){
^
Main.java:16: error: class, interface, or enum expected
g.push_back(tmp);
^
Main.java:17: error: class, interface, or enum expected
}
^
Main.java:19: error: class, interface, or enum expected
if (g[n] - g[1]>l) { cout << 0; return 0; }
^
Main.java:19: error: class, interface, or enum expected
if (g[n] - g[1]>l) { cout << 0; return 0; }
^
Main.java:19: error: class, interface, or enum expected
if (g[n] - g[1]>l) { cout << 0; return 0; }
^
Main.java:21: error: class, interface, or enum expected
const int maxvol = g[1] + l; //max volumn
^
Main.java:23: error: class, interface, or enum expected
vector<int>::iterator it;
^
Main.java:24: error: class, interface, or enum expected
if (find(g.begin(), g.end(), maxvol ) != g.end()) {
^
Main.java:26: error: class, interface, or enum expected
posMaxVol = it - g.begin() - 1;
^
Main.java:27: error: class, interface, or enum expected
}
^
Main.java:30: error: class, interface, or enum expected
posMaxVol = it - g.begin();
^
Main.java:31: error: class, interface, or enum expected
}
^
Main.java:34: error: class, interface, or enum expected
long long ans = 0;
^
Main.java:35: error: class, interface, or enum expected
while (cntDu>0){
^
Main.java:37: error: class, interface, or enum expected
ans += g[posMaxVol];
^
Main.java:38: error: class, interface, or enum expected
posMaxVol--;
^
Main.java:39: error: class, interface, or enum expected
}
^
Main.java:40: error: class, interface, or enum expected
for (int i = 1; i <= posMaxVol; i += k){
^
Main.java:40: error: class, interface, or enum expected
for (int i = 1; i <= posMaxVol; i += k){
^
Main.java:42: error: class, interface, or enum expected
}
^
Main.java:45: error: class, interface, or enum expected
return 0;
^
Main.java:46: error: class, interface, or enum expected
}
^
34 errors