답안 #1087418

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087418 2024-09-12T16:14:15 Z guymmk Izbori (COCI17_izbori) C++14
10 / 80
3000 ms 440 KB
#include <bits/stdc++.h>
using namespace std;
int n,m,k;
int kk[25];
int cnt[25];
vector<vector<int>>s;
int f(int i){
    if(i==n)return 1e9;
    int mx=0,mxi=0;
    for(int i=1;i<=m;i++){
        if(cnt[i]>mx)mx=cnt[i],mxi=i;
    }
    if(mxi==k)return 0;
    int ret=f(i+1);
    int c=0;
    cnt[s[i][0]]--;
    cnt[k]++;
    ret=min(ret,f(i+1)+kk[i]+1);
    return ret;
}
int main(){
    cin>>n>>m>>k;
    s.resize(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int x;
            cin>>x;
            s[i].push_back(x);if(k==x)kk[i]=j;
        }
    }int mx=0,mxi=0;
    for(int i=0;i<n;i++){
        cnt[s[i].front()]++;
    }for(int i=1;i<=m;i++){
        if(cnt[i]>mx)mx=cnt[i],mxi=i;
    }cout<<mxi<<endl;
    cout<<f(0)<<endl;
}

Compilation message

izbori.cpp: In function 'int f(int)':
izbori.cpp:15:9: warning: unused variable 'c' [-Wunused-variable]
   15 |     int c=0;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3039 ms 344 KB Time limit exceeded
2 Partially correct 0 ms 348 KB Partially correct
3 Execution timed out 3096 ms 348 KB Time limit exceeded
4 Execution timed out 3035 ms 344 KB Time limit exceeded
5 Incorrect 0 ms 348 KB Output isn't correct
6 Partially correct 0 ms 348 KB Partially correct
7 Incorrect 0 ms 348 KB Output isn't correct
8 Correct 0 ms 348 KB Output is correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Partially correct 0 ms 348 KB Partially correct
11 Execution timed out 3097 ms 440 KB Time limit exceeded
12 Execution timed out 3074 ms 344 KB Time limit exceeded
13 Incorrect 0 ms 344 KB Output isn't correct
14 Execution timed out 3040 ms 348 KB Time limit exceeded
15 Incorrect 0 ms 344 KB Output isn't correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Execution timed out 3093 ms 348 KB Time limit exceeded
18 Execution timed out 3051 ms 348 KB Time limit exceeded
19 Execution timed out 3054 ms 348 KB Time limit exceeded
20 Execution timed out 3070 ms 344 KB Time limit exceeded