Submission #584203

# Submission time Handle Problem Language Result Execution time Memory
584203 2022-06-27T03:27:41 Z talant117408 Olympiads (BOI19_olympiads) C++17
44 / 100
2000 ms 544 KB
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

#define long                unsigned long 
#define pb                  push_back
#define mp                  make_pair
#define all(v)              (v).begin(),(v).end()
#define rall(v)             (v).rbegin(),(v).rend()
#define lb                  lower_bound
#define ub                  upper_bound
#define sz(v)               int((v).size())
#define do_not_disturb      ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl                '\n'
#define PI                  2*acos(0.0)

int n, k;
ll grid[500][6], c;
multiset <int> scores;
vector <int> inds;

void calc(int i, int cnt) {
    if (cnt == k) {
        ll val = 0;
        for (int j = 0; j < k; j++) {
            ll mx = 0;
            for (int l = 0; l < k; l++) {
                mx = max(mx, grid[inds[l]][j]);
            }
            val += mx;
        }
        scores.insert(val);
        if (sz(scores) > c) {
            scores.erase(scores.begin());
        }
        return;
    }
    if (i == n) return;
    inds.pb(i);
    for (int j = i+1; j <= n; j++) {
        calc(j, cnt+1);
        if (cnt+1 == k) break;
    }
    inds.pop_back();
}

void solve() {
    cin >> n >> k >> c;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
            cin >> grid[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        calc(i, 0);
    }
    cout << (*scores.begin());
}   
int main() {
    do_not_disturb
    
    int t = 1;
    //~ cin >> t;
    while (t--) {
        solve();
    }
    
    return 0;
}
/*

*/
# Verdict Execution time Memory Grader output
1 Correct 10 ms 544 KB Output is correct
2 Correct 10 ms 340 KB Output is correct
3 Correct 8 ms 340 KB Output is correct
4 Correct 14 ms 452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 345 ms 412 KB Output is correct
2 Correct 359 ms 396 KB Output is correct
3 Correct 336 ms 396 KB Output is correct
4 Correct 344 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2071 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 544 KB Output is correct
2 Correct 10 ms 340 KB Output is correct
3 Correct 8 ms 340 KB Output is correct
4 Correct 14 ms 452 KB Output is correct
5 Correct 345 ms 412 KB Output is correct
6 Correct 359 ms 396 KB Output is correct
7 Correct 336 ms 396 KB Output is correct
8 Correct 344 ms 460 KB Output is correct
9 Execution timed out 2071 ms 340 KB Time limit exceeded
10 Halted 0 ms 0 KB -