fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int n, k, l;
  10. cin >> n >> k >> l;
  11. int m = n*k;
  12. vector<int> g(1,0);
  13. int tmp;
  14. for (int i = 1; i <= m; i++){
  15. cin >> tmp;
  16. g.push_back(tmp);
  17. }
  18. sort(g.begin(), g.end());
  19. if (g[n] - g[1]>l) { cout << 0; return 0; }
  20. int posMaxVol;
  21. const int maxvol = g[1] + l; //max volumn
  22.  
  23. vector<int>::iterator it;
  24. if (find(g.begin(), g.end(), maxvol ) != g.end()) {
  25. it = upper_bound(g.begin(), g.end(), maxvol);
  26. posMaxVol = it - g.begin() - 1;
  27. }
  28. else{
  29. it = lower_bound(g.begin(), g.end(), maxvol);
  30. posMaxVol = it - g.begin();
  31. }
  32.  
  33. int cntDu = m - posMaxVol;
  34. long long ans = 0;
  35. while (cntDu>0){
  36. cntDu -= (k - 1);
  37. ans += g[posMaxVol];
  38. posMaxVol--;
  39. }
  40. for (int i = 1; i <= posMaxVol; i += k){
  41. ans += g[i];
  42. }
  43. cout << ans;
  44.  
  45. return 0;
  46. }
  47.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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
stdout
Standard output is empty