답안 #1087352

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1087352 2024-09-12T14:14:05 Z idk__ Rasvjeta (COCI17_rasvjeta) C++17
0 / 50
12 ms 8284 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long



signed main() {
    int n, m, k;
    cin >> n >> m >> k;
    int a[n][m];
    for(int i = 0;i < n; i++){
        for(int j = 0;j < m ;j++){
            cin >> a[i][j];
        }
    }
    int cnt[16] = {};
    int count=-1, num=0;
    for(int i = 0;i < n; i++){
        int& curr = a[i][0];
        cnt[curr]++;
        if(cnt[curr] > count)num = curr, count=cnt[curr];
        else if(cnt[curr] == count){
            if(curr > num){
                num =curr;
                count =cnt[curr];
            }
        }
    }
    cout << num << endl;
    int poi[n] = {}, ans = 0;
    while(true){
        for(int i = 0;i < 16; i++)cnt[i] = 0;
        count=-1, num=-1;
        for(int i = 0;i < n; i++){
        int& curr = a[i][poi[i]];

        cnt[curr]++;
        if(cnt[curr] > count)num = curr, count=cnt[curr];
        else if(cnt[curr] == count){
            if(curr > num){
                num = curr;
                count = cnt[curr];
            }
        }
        
        }

        if(num == k)break;
        for(int i = 0;i < n; i++){
            if(poi[i]<m and num==a[i][poi[i]]  )poi[i]++;
        }
        
        ans++;
        
    }
  cout << ans << endl;
    
    
    }
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 11
2 Runtime error 1 ms 344 KB Execution killed with signal 11
3 Runtime error 2 ms 1980 KB Execution killed with signal 11
4 Runtime error 8 ms 8284 KB Execution killed with signal 11
5 Runtime error 5 ms 5212 KB Execution killed with signal 11
6 Runtime error 3 ms 3676 KB Execution killed with signal 11
7 Runtime error 2 ms 2140 KB Execution killed with signal 11
8 Runtime error 7 ms 6772 KB Execution killed with signal 11
9 Runtime error 12 ms 6748 KB Execution killed with signal 11
10 Incorrect 10 ms 6236 KB Output isn't correct