ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1644. A Whole Lot of Walnuts

WA#15. I posted my C code
Posted by SpartakusMd 15 Mar 2012 16:32
Hi. I've got WA on test 15. Here is my C code:

/**
 * No: 1644
 */
#include <stdio.h>
#include <conio.h>
#include <string.h>

int main() {
    int n, i, a[101][2]={0}, maxs=0, mins=10, maxh=0;
    char s[15];
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d%s", &a[i][0], &s);
        if(strcmp(s, "satisfied") == 0) a[i][1] = 1;
    }

    for(i=0; i<n; i++)
        if(a[i][1] == 1) {
            if(maxs < a[i][0]) maxs = a[i][0];
            if(mins > a[i][0]) mins = a[i][0];
        } else {
            if(maxh < a[i][0]) maxh = a[i][0];
        }

    if(maxs==0 && mins==10) printf("10");
    else if(maxh >= maxs) printf("Inconsistent");
    else {
        for(i=0; i<n; i++)
            if(a[i][0] > maxh && a[i][1] == 1 && maxs > a[i][0]) maxs = a[i][0];
        printf("%d", maxs);
    }


    return 0;
}

Edited by author 15.03.2012 16:34