답안 #586957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
586957 2022-07-01T06:26:24 Z 반딧불(#8396) Olympiads (BOI19_olympiads) C++17
44 / 100
2000 ms 23800 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, k, c;
int mat[502][10];
vector<int> vec;

int cnt[6000002];
int best[10];
int sum;

void dfs(int x, int col){ /// x�� �� ���ʰ�, ���ݱ��� col�� �����
    if(col==k){ /// �� ����
        cnt[sum]++;
        return;
    }
    if(x==n+1) return;
    dfs(x+1, col);
    vector<pair<int, int> > v;
    for(int i=0; i<k; i++){
        if(best[i] < mat[x][i]){
            v.push_back(make_pair(i, best[i]));
            sum += mat[x][i] - best[i];
            best[i] = mat[x][i];
        }
    }
    dfs(x+1, col+1);
    for(pair<int, int> p: v){
        sum -= best[p.first] - p.second;
        best[p.first] = p.second;
    }
}

int main(){
    scanf("%d %d %d", &n, &k, &c);
    for(int i=1; i<=n; i++) for(int j=0; j<k; j++) scanf("%d", &mat[i][j]);
    dfs(1, 0);
    for(int i=6000000; i>=0; i--){
        int p = min(c, cnt[i]);
        c -= p, cnt[i] -= p;
        if(!c){
            printf("%d", i);
            break;
        }
    }
}

Compilation message

olympiads.cpp: In function 'int main()':
olympiads.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |     scanf("%d %d %d", &n, &k, &c);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
olympiads.cpp:39:57: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |     for(int i=1; i<=n; i++) for(int j=0; j<k; j++) scanf("%d", &mat[i][j]);
      |                                                    ~~~~~^~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 22732 KB Output is correct
2 Correct 22 ms 23788 KB Output is correct
3 Correct 22 ms 23800 KB Output is correct
4 Correct 13 ms 15936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 221 ms 16532 KB Output is correct
2 Correct 185 ms 16008 KB Output is correct
3 Correct 261 ms 17876 KB Output is correct
4 Correct 241 ms 18228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2073 ms 340 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 22732 KB Output is correct
2 Correct 22 ms 23788 KB Output is correct
3 Correct 22 ms 23800 KB Output is correct
4 Correct 13 ms 15936 KB Output is correct
5 Correct 221 ms 16532 KB Output is correct
6 Correct 185 ms 16008 KB Output is correct
7 Correct 261 ms 17876 KB Output is correct
8 Correct 241 ms 18228 KB Output is correct
9 Execution timed out 2073 ms 340 KB Time limit exceeded
10 Halted 0 ms 0 KB -