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

Обсуждение задачи 1005. Куча камней

help!!why my programme is wrong!i find no mistake in it!
Послано olive 5 май 2005 09:05
#include<stdio.h>
int main(){
    int stonenumber;
    int i,j;
    long int s=0,t=0,a[20],u,minweight;
    scanf("%d",&stonenumber);
    for(i=0;i<stonenumber;i++)
        scanf("%d",&a[i]);
    for(j=0;j<stonenumber-1;j++)
        for(i=0;i<stonenumber-j-1;i++)
            if(a[i]>a[i+1])
            {u=a[i];a[i]=a[i+1];a[i+1]=u;}
            s=a[stonenumber-1];
            t=a[stonenumber-2];
       for(i=stonenumber-3;i>=0;i--)
        if(t<s||t==s) t=t+a[i];
        else s=s+a[i];
    if(s>t) minweight=s-t;
    else minweight=t-s;
    printf("%d",minweight);
    return 0;
}




please reply me:287662136@163.com

Edited by author 05.05.2005 09:07

Edited by author 05.05.2005 09:07
Re: help!!why my programme is wrong!i find no mistake in it!
Послано beise 4 окт 2006 12:52
5
2000
3
4
5
6
The correct answer should be 1988,and what's your answer?
Re: help!!why my programme is wrong!i find no mistake in it!
Послано Kirin Vladislav 1 ноя 2006 00:29
how can be the correct answer 1988 if we put one stone 2000 in then one heap and other stones (3+4+5+6=18) in then second heap? 2000-18=1982 not a 1988
Re: help!!why my programme is wrong!i find no mistake in it!
Послано hsejiv 27 апр 2007 16:59
Can you explain your solution?
I'm struck with test 5!
Re: help!!why my programme is wrong!i find no mistake in it!
Послано FireHeart 28 апр 2007 16:28
yeah, my answer is 1982, but I have wrong answer on test 1
Re: help!!why my programme is wrong!i find no mistake in it!
Послано timur 24 ноя 2007 02:21
try this test:

5
3 3 2 2 2

the correct answer is 0. your program gives 2.

Edited by author 24.11.2007 02:22