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 1210. Kind Spirits

AC 0.093 143 Kb
Posted by Виктор Крупко 1 May 2005 22:33
Whether it is possible better?
Re: AC 0.093 143 Kb
Posted by Nirjon 29 May 2005 00:29
Accepted
 0.015 286 KB
+++++++++++++++++
Posted by Виктор Крупко 29 May 2005 02:37
xxvictorxx@mail.ru
Re: AC 0.093 143 Kb
Posted by wangyin 4 Jul 2006 08:39
Mine is 0.015s 178k
Re: AC 0.093 143 Kb
Posted by PSV 7 Jul 2006 22:29
0.015    166 КБ :D See I have you write down if you want to know how it can be :D
Re: AC 0.093 143 Kb
Posted by Нищий Наглец 8 Jul 2006 02:42
Виктор Крупко wrote 1 May 2005 22:33
Whether it is possible better?

see and train.

http://acm.timus.ru/status.aspx?space=1&num=1210&author=31927
Re: AC 0.093 143 Kb
Posted by PSV 8 Jul 2006 05:35
0.015 132 Kb - now by changing longint to integer :D
Re: AC 0.093 143 Kb
Posted by hoan 16 Nov 2010 19:36
0.031 104kb
Re: AC 0.093 143 Kb
Posted by Надежда Халтурина 8 Apr 2011 17:12
#include "iostream"
using namespace std;
void main ()
{
    long n,lay,from,fee;
    long i=0;
    long j;

    long arr[35];
    long arr2[35];
    long* one;
    long* two;
    long* help;
    char c;

    for (i=0;i<35;i++)
    {
        arr2[i]=0;
        arr[i]=0;
    };
    one=arr;
    two=arr2;

    cin>>n;

    for (i=0;i<n;i++)
    {
        cin>>lay;
        for (j=0;j<lay;j++)
        {
            cin>>from;
            if (from==0)
                    { continue;}
            cin>>fee;
            two[j+1]=one[from]+fee;
            while(2>1)
            {
                cin>>from;
                if (from==0)
                    { break;}
                cin>>fee;
                if (two[j+1]>(one[from]+fee))
                {
                    two[j+1]=one[from]+fee;
                };
            };
        };

        if (i!=n-1)
        {
            help=one;
            one=two;
            two=help;
            cin>>c;
        };
    };

    long m;

    m=two[1];
    for (j=1;j<lay;j++)
        if (m>two[j+1])
            m=two[j+1];
    cout<<m;

}