Submission #1087516

# Submission time Handle Problem Language Result Execution time Memory
1087516 2024-09-12T19:55:56 Z idk__ Izbori (COCI17_izbori) C++14
48 / 80
1 ms 604 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 101, M = 16;
int n, m, k, num, ans=0, poi[N], a[N][M], cnt[M];

int main() {
    int count;
    cin >> n >> m >> k;

    for(int i = 0;i < n; i++){
        for(int j = 0;j < m ;j++){
            cin >> a[i][j];
        }
    }
    
    while(true){
        
        count=0, num=-1;
        for(int i = 0;i < M; i++)cnt[i]=0;

        for(int i = 0;i < n; i++){
        while(true){
            if(a[i][poi[i]]==-5)poi[i]++;
            else break;

        }
        if(poi[i]==m)continue;
        int& curr = a[i][poi[i]];
        


        cnt[curr]++;
        if((cnt[curr] > count) or (cnt[curr] == count and curr < num)){
            num = curr;
            count=cnt[curr];
        }
        
        
        }
        if(ans==0)cout << num << endl;
        if(num == k or ans == m-1)break;
       
       
        for(int i = 0;i < n; i++){
            for(int j = 0;j < m; j++){
                if(a[i][j]==num)a[i][j]=-5;

            }
        }
        
        ans++;
        
    }
  cout << min(ans, m-1) << endl;
    
    
    }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Partially correct 0 ms 440 KB Partially correct
4 Partially correct 0 ms 348 KB Partially correct
5 Partially correct 0 ms 348 KB Partially correct
6 Partially correct 0 ms 348 KB Partially correct
7 Partially correct 0 ms 348 KB Partially correct
8 Partially correct 0 ms 348 KB Partially correct
9 Partially correct 0 ms 348 KB Partially correct
10 Partially correct 0 ms 348 KB Partially correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Partially correct 0 ms 348 KB Partially correct
14 Partially correct 1 ms 440 KB Partially correct
15 Partially correct 0 ms 348 KB Partially correct
16 Partially correct 0 ms 348 KB Partially correct
17 Partially correct 0 ms 348 KB Partially correct
18 Partially correct 1 ms 604 KB Partially correct
19 Partially correct 1 ms 348 KB Partially correct
20 Partially correct 0 ms 348 KB Partially correct