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 1005. Stone Pile

В среде DevC++ все работает правильно и по условию, а на сайте выдает Wrong answer.
Posted by LDGoD 18 Sep 2016 12:53
#include <iostream>

using namespace std;

int main(){
    int n, r, g, d, t, y = 0, i = 0,h = 0;
    cin>>n;
    r = n;
    g = n - 2;
    t = n;
    d = n;
    float w[n], w2[n];
    float a = 0, b = 0, c, k;
    for(;n>0;n--){
        cin>>w[i];
        i++;
    }
    i = 0;
    n = r;
    c = w[0];
    for(;r>0;r--){
        for(;n>0;n--){
            i++;
            k = c;
            c = c - w[i];
            if(c < 0)
                c = w[i];
            else
                c = k;
        }
        i = 0;
        while(w[i] != c){
            y++;
            i++;

        }
        n = d;
        t = d;
        w[y] = 0;
        y = 0;
        i = -1;
        w2[h] = c;
        c = 0;
        h++;
    }
    i = 0;
    a = a + w2[i];
    b = b + w2[i+1];
    i = 2;
    for(;g>0;g--){
        if(b <= a){
            b = b + w2[i];
        } else{
            a = a + w2[i];
        }
        i++;
    }
    c = a - b;
    if(c<0){
        c = b - a;
    }
    cout<<c;
    return 0;
}
Re: В среде DevC++ все работает правильно и по условию, а на сайте выдает Wrong answer.
Posted by Smilodon_am [Obninsk INPE] 19 Sep 2016 15:31
Your algo isn't right. Correct algorithm is absolutely another - use full search. Try tests from forum for this task and so you will understand that your solution isn't correct.