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

I think program is ok, but I got WA#1
Posted by Zashi 8 Apr 2011 03:26
#include<iostream>
using namespace std;

int main(){
    int n,y=100001;
    int x=0;
    cin >> n;

    int *array = new int[n];

    for( int i=0; i<n; i++ )
    {
        cin >> array[i];
    }

    for (int i=0; i<n; i++)
    {
            x = (array[i+1] - array[i]);
            if(x < y && x >= 0) { y = x; }
    }

    cout << y;
    system("PAUSE");
    return 0;
}

----------------------------------------------------------------
Why WA#1?

I got 3 for:
5
5 8 13 27 14


So? Does someone know?
I think program is ok, but I got WA#1
Posted by Lock 5 Oct 2011 02:15
WA - Wrong Algorithm