/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 284.0 KiB
#2 Wrong Answer 1ms 284.0 KiB

Code

#include <stdio.h>

// Function to find the possible winner of the game
char* find_winner(int N, char* rounds) {
    int mahfuz_points = 0;
    int emon_points = 0;
    int k = 0;
    
    for (int i = 0; i < N; i++) {
        char round_result = rounds[i];
        if (round_result == 'M') {
            mahfuz_points += 1;
        } else if (round_result == 'E') {
            emon_points += 1;
        } else {  // round_result == '?'
            k += 1;
        }
        
        if (mahfuz_points >= k && mahfuz_points >= emon_points) {
            return "Mahfuz";
        } else if (emon_points >= k && emon_points > mahfuz_points) {
            return "Emon";
        }
    }
    
    return "IDK";
}

int main() {
    int N;
    scanf("%d", &N);
    
    char rounds[N + 1];
    scanf("%s", rounds);

    // Output
    char* winner = find_winner(N, rounds);
    printf("%s\n", winner);

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1031 Clash of programmers
Contest
Brain booster #2
Language
C99 (GCC 13.2.0)
Submit At
2024-03-06 16:03:31
Judged At
2024-11-11 03:41:27
Judged By
Score
0
Total Time
1ms
Peak Memory
284.0 KiB