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

I give up ,WA#12
Posted by Pegasus 22 Sep 2012 21:10
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> ivec;
    vector<string> svec;
    int val;
    string s;
    for (int i = 0; i < n; ++i)
    {
        cin >> val;
        ivec.push_back(val);
        cin >> s;
        svec.push_back(s);
    }
    if (n == 0)
    {    cout << 10 <<endl;    return 0;}
    if (n == 1)
    {
        if (svec[0] == "satisfied")
        {    cout << ivec[0] << endl;    return 0;}
        if (svec[0] == "hungry")
        {    cout << 10 << endl;    return 0;}
    }
    int hungry[100]={0},satisfied[100]={0};
    int hungry_num=0,satisfied_num=0;
    for (int i = 0; i < n; ++i)
    {
        if (svec[i] == "hungry")
        {
            hungry[hungry_num++] = ivec[i];
        }
        if (svec[i] == "satisfied")
        {
            satisfied[satisfied_num++] = ivec[i];
        }
    }
    sort(hungry, hungry+hungry_num);
    sort(satisfied, satisfied+satisfied_num);
    if (hungry[hungry_num-1] >= satisfied[0])
    {
            cout << "Inconsistent" << endl;
            return 0;
    }
    cout << satisfied[0] << endl;
    return 0;
}
Re: I give up ,WA#12
Posted by Pegasus 22 Sep 2012 21:11
When n == 0; What is the answer?
Re: I give up ,WA#12
Posted by O.K. 24 Sep 2012 21:58
if n==0 answer is 10

Edited by author 24.09.2012 21:58