fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. #include <ext/pb_ds/assoc_container.hpp>
  4. #include <ext/pb_ds/tree_policy.hpp>
  5. #define ll long long
  6. #define ld long double
  7. #define endl "\n"
  8. #define ON(n , k) ((n) | (1 << (k)))
  9. #define OFF(n , k) ((n) & ~(1 << (k)))
  10. #define isON(n , k) (((n) >> (k)) & 1)
  11. #define IN() freopen("bad-memes.in", "r", stdin);
  12. using namespace __gnu_pbds;
  13. using namespace std;
  14. typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderSet;
  15. void Erase(orderSet &s, int val) {
  16. int rank = s.order_of_key(val);
  17. auto it = s.find_by_order(rank);
  18. s.erase(it);
  19. }
  20. bool is_prime(ll n) {
  21. if(n<2) {
  22. return false;
  23. }
  24. for (int i=2;i*i<=n;++i) {
  25. if(n%i==0) {
  26. return false;
  27. }
  28. }
  29. return true;
  30. }
  31.  
  32. vector<ll> divisors(ll x) {
  33. vector<ll> divs;
  34. for (int i = 1; i * i <= x; i++) {
  35. if (x % i == 0) {
  36. divs.push_back(i);
  37. if (i != x / i) {
  38. divs.push_back(x / i);
  39. }
  40. }
  41. }
  42. sort(divs.begin(), divs.end());
  43. return divs;
  44. }
  45. map<ll, ll> factors(ll n) {
  46. map<ll, ll> fact;
  47. while (n % 2 == 0) {
  48. fact[2]++;
  49. n /= 2;
  50. }
  51. for (ll i = 3; i * i <= n; i += 2) {
  52. while (n % i == 0) {
  53. fact[i]++;
  54. n /= i;
  55. }
  56. }
  57. if (n > 2) {
  58. fact[n]++;
  59. }
  60. return fact;
  61. }
  62.  
  63. ll lcm(ll a, ll b)
  64. {
  65. return a * (b / __gcd(a, b));
  66. }
  67.  
  68. ll gcd(ll a, ll b) {
  69. while (b != 0) {
  70. ll temp = b;
  71. b = a % b;
  72. a = temp;
  73. }
  74. return a;
  75. }
  76.  
  77. ll factorial(ll n) {
  78. ll f=1;
  79. while (n>0) {
  80. f=f*n;
  81. n--;
  82. }
  83. return f;
  84. }
  85. //const int mod=1e9+7;
  86. double root(double x, double n) {
  87. return pow(x, 1.0 / n);
  88. }
  89. void manar()
  90. {
  91. ios_base::sync_with_stdio(false);
  92. cin.tie(NULL);
  93. cout.tie(NULL);
  94. }
  95. bool is_even(int n) {
  96. if((n&1)==0) {
  97. return 1;
  98. }
  99. else {
  100. return 0;
  101. }
  102. }
  103. bool get_bit(ll n,int k) {
  104. int msk=1LL<<k; //value
  105. return (n&msk)? 1 : 0; //if value not =0 return true
  106. }
  107. int set_bit(ll n,int k) { // set k bit to 1
  108. int msk=1LL<<k;
  109. return n|msk;
  110. }
  111. int flip_bit(ll n,int i) {
  112. int msk=1LL<<i;
  113. return n^msk;
  114. }
  115. const int MOD=1e9;
  116. ll fast_pow(long long n, long long k) {
  117. long long result = 1;
  118. while (k > 0) {
  119. if (k & 1) {
  120. result = (result * n) % MOD;
  121. }
  122. n = (n * n) % MOD;
  123. k >>= 1;
  124. }
  125. return result;
  126. }
  127. ll count_ones(ll n) {
  128. int cnt=0;
  129. while (n) {
  130. n=n&(n-1);
  131. cnt++;
  132. }
  133. return cnt;
  134. }
  135. bool is_power_of_two(int n) {
  136. if(n&&((n&n-1))==0) {
  137. return 1;
  138. }
  139. else {
  140. return 0;
  141. }
  142. }
  143. vector<ll>sums;
  144. vector<vector<ll>> gen_sub(ll n, vector<ll> arr) {
  145. vector<vector<ll>> ans;
  146. for (int i = 0; i < (1 << n); i++) {
  147. vector<ll> tmp;
  148. ll sum = 0;
  149. for (int j = 0; j < n; j++) {
  150. if (isON(i, j)) {
  151. tmp.push_back(arr[j]);
  152. sum += arr[j];
  153. }
  154. }
  155. sums.push_back(sum);
  156. ans.push_back(tmp);
  157. }
  158. return ans;
  159. }
  160.  
  161. vector<string>sub(string s) {
  162. vector<string> ans;
  163. int n = s.size();
  164. ans.push_back("");
  165. for (int i = 1; i < (1 << n); ++i) {
  166. string tmp = "";
  167. for (int j = 0; j < n; ++j) {
  168. if (i & (1 << j)) {
  169. tmp += s[j];
  170. }
  171. }
  172. ans.push_back(tmp);
  173. }
  174.  
  175. return ans;
  176. }
  177. string get_binary(ll x)
  178. {
  179. string ret = "";
  180. bool tmp = false;
  181. for(int i = 63; i > -1; i--)
  182. {
  183. if(isON(x, i))
  184. tmp = true;
  185. if(tmp)
  186. ret += to_string(isON(x, i));
  187. }
  188. return ret;
  189. }
  190. long long lowbit(long long x) {
  191. return x & -x;
  192. }
  193. bool is_palindrome(string s) {
  194. int l = 0, r = s.size() - 1;
  195. while (l < r) {
  196. if (s[l] !=s[r]) {
  197. return false;
  198. }
  199. l++;
  200. r--;
  201. }
  202. return true;
  203. }
  204. const int mod=1e9+7;
  205. ll powmod(ll x, ll y, ll mod)
  206. {
  207. ll res = 1;
  208. x = x % mod;
  209. if (x == 0) return 0;
  210. while (y > 0)
  211. {
  212. if (y & 1)
  213. res = (res*x) % mod;
  214. y = y>>1;
  215. x = (x*x) % mod;
  216. }
  217. return res;
  218. }
  219. ll add(ll a,ll b)
  220. {
  221. return ((a%mod)+(b%mod))%mod;
  222. }
  223. ll mul(ll a,ll b)
  224. {
  225. return ((a%mod)*(b%mod))%mod;
  226. }
  227. ll sub(ll a,ll b)
  228. {
  229. return ((((a%mod)-(b%mod))%mod)+mod)%mod;
  230. }
  231. const int n = 1e6 + 1;
  232. int divcnt[n + 1];
  233. void cntDiv()
  234. {
  235. for(int i = 1; i <= n; i++)
  236. {
  237. for(int j = i; j <= n; j+= i)
  238. divcnt[j]++;
  239. }
  240. }
  241. const int N=1e7+10;
  242. vector<bool> isPrime(N,true);
  243. vector<int>v;
  244. void sieve() {
  245. isPrime[0] = false;
  246. isPrime[1] = false;
  247.  
  248. for(ll i=2;i*i<N;i++)
  249. {
  250. if(isPrime[i])
  251. {
  252. for(ll j=i*i;j<N;j+=i)
  253. {
  254. isPrime[j] = false;
  255. }
  256. }
  257. }
  258. for (int i = 2; i < N; i++) {
  259. if (isPrime[i]) {
  260. v.push_back(i);
  261. }
  262. }
  263. }
  264.  
  265. void manora() {
  266. ll n, m, k;
  267. cin >> n >> m >> k;
  268. vector<vector<ll>> arr(m);
  269.  
  270. for (ll i = 0; i < n; ++i) {
  271. for (ll j = 0; j < m; ++j) {
  272. ll x;
  273. cin >> x;
  274. arr[j].push_back(x);
  275. }
  276. }
  277. for (ll j = 0; j < m; ++j) {
  278. sort(arr[j].rbegin(), arr[j].rend());
  279. }
  280. priority_queue<ll> pq;
  281. for (ll j = 0; j < m; ++j) {
  282. for (ll i = 0; i < min(n,j+1); ++i) {
  283. pq.push(arr[j][i]);
  284. }
  285. }
  286. if (k == 0) {
  287. cout << 0 << endl;
  288. return;
  289. }
  290. long double sum = 0;
  291. while (k >= 0 && !pq.empty()&&pq.top()>0) {
  292. sum += pq.top();
  293. pq.pop();
  294. k--;
  295. }
  296. cout << sum << endl;
  297. }
  298. int main() {
  299.  
  300. manar();
  301. manora();
  302. /* int t;
  303.   cin>>t;
  304.   while (t--) {
  305.  
  306.   manora();
  307.   }
  308.   */
  309.  
  310.  
  311. return 0;
  312. }
  313.  
  314.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
0