# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
863093 | 2023-10-19T15:14:27 Z | Benmath | Olympiads (BOI19_olympiads) | C++14 | 829 ms | 19608 KB |
#include <bits/stdc++.h> using namespace std; int niz[41][7]; int n, k , c; int solve(vector<int>indeksi){ int maxi[k]; for(int i = 0; i < k; i++){ maxi[i] = 0; } for(int i = 0; i < indeksi.size(); i++){ int tren = indeksi[i]; for(int j = 0; j < k; j++){ maxi[j] = max(maxi[j], niz[tren][j]); } } int sum = 0; for(int i = 0; i < k; i++){ sum = sum + maxi[i]; } return sum; } int main(){ cin >> n >> k >> c; for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ cin >> niz[i][j]; } } int so = n / 2; vector<int>vector1[n + 1]; vector<int>vector2[n + 1]; for(int i = 0; i < so; i ++){ for(int j = 0; j < k; j++){ vector1[i].push_back(niz[i][j]); } } for(int i = so; i < n; i++){ for(int j = 0; j < k; j++){ vector2[i - so].push_back(niz[i][j]); } } int size1 = so; int size2 = n - so; vector<int>v1[k + 1]; vector<int>v2[k + 1]; vector<int>ans; for(int i = 0; i < (1<<size1); i++){ int brojac = 0; for(int j = 0; j < size1; j++){ int res = i & (1<<j); if(res != 0){ brojac++; } } if(brojac <= k){ v1[brojac].push_back(i); } } for(int i = 0; i < (1<<size2); i++){ int brojac = 0; for(int j = 0; j < size2; j++){ int res = i & (1<<j); if(res != 0){ brojac++; } } if(brojac <= k){ v2[brojac].push_back(i); } } for(int i = 0; i < k; i++){ int velicina = v1[i].size(); for(int j = 0; j < velicina; j ++){ vector<int>prvi_indeksi; int x = v1[i][j]; for(int j1 = 0; j1 < size1; j1++){ int res = x & (1<<j1); if(res != 0){ prvi_indeksi.push_back(j1); } } int velicina2 = v2[k - i].size(); for(int t = 0; t < velicina2; t++){ vector<int>indeksi = prvi_indeksi; int x = v2[k - i][t]; for(int j1 = 0; j1 < size2; j1++){ int res = x & (1<<j1); if(res != 0){ indeksi.push_back(j1 + so); } } ans.push_back(solve(indeksi)); } } } sort(ans.begin(),ans.end()); int to = ans.size(); cout << ans[to - c]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 817 ms | 18164 KB | Output is correct |
2 | Correct | 816 ms | 19608 KB | Output is correct |
3 | Correct | 829 ms | 17864 KB | Output is correct |
4 | Incorrect | 813 ms | 18864 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 348 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |