ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1190. Плитка шоколада

Показать все сообщения Спрятать все сообщения

Please help me with this problem... test my program.. Reshetnikov Eugeny 8 мар 2002 23:28
This is my program! Please give me some tests and said what my
program must write, and why... Please help!

Program n1190;
  Var n,sum,x,count,i,min:longint;
      code               :integer;
      s                  :string[255];

Procedure Input_Solve;
  Begin
    ReadLn(n);
    min:=0; count:=0; sum:=0;
    While n>0 Do Begin
      n:=n-1;
      ReadLn(s);
      Delete(s,1,Pos(' ',s));
      If Copy(s,1,1)='0' Then count:=count+1
      Else Begin
        Delete(s,1,2);
        Val(s,x,code);
        If min=0 Then min:=x Else
        If min>x Then min:=x Else
        If x>min Then sum:=10001;
        sum:=sum+(count+1)*x;
        count:=0;
      End;
    End;
    If (count>0) and (sum<10000) and (count*min+sum>=10000) Then
      sum:=10000;
    If (count>0) and (min=0) Then
      sum:=10000;
  End;

Procedure Write_It;
  Begin
    If sum<>10000 Then WriteLn('NO') Else WriteLn('YES');
  End;

Begin
  Input_Solve;
  Write_It;
End.
It's easy(+) Nazarov Denis (nsc2001@rambler.ru) 10 мар 2002 13:48
5
a1 1 2001
a2 0
a3 0
a4 0
a5 1 1999

Rigth answer - YES
Really,
a1 = 2001
a2 = 2000
a3 = 2000
a4 = 2000
a5 = 1999

a1+a2+a3+a4+a5=10000

Why?
See:

min(a1+a2+a3+a4+a5)=2001+1999+1999+1999+1999=9997
max(a1+a2+a3+a4+a5)=2001+2001+2001+2001+1999=10003

As min(a1+a2+a3+a4+a5)<=10000<=max(a1+a2+a3+a4+a5) we must write "YES"