Page 1 of 1

11078 - Open Credit System

Posted: Sat Sep 02, 2006 6:05 pm
by Ghust_omega
Hi to all!

I getting WA in this one mi algo is:

if i < j then "i" is senior and j is junior
so I take the diference of S_i - Min ( S_J ) where i<j<=n

then take the maximun of this diferences

Thanks in advance

Re: 11078 WA

Posted: Sat Sep 02, 2006 9:18 pm
by Martin Macko
Ghust_omega wrote:Hi to all!

I getting WA in this one mi algo is:

if i < j then "i" is senior and j is junior
so I take the diference of S_i - Min ( S_J ) where i<j<=n

then take the maximun of this diferences

Thanks in advance
Yes, your approach is correct... You have a bug in your code probably...

Try:

Code: Select all

4
2
149999
-149999
2
-149999
149999
2
47
47
7
32652
652
2642
642
-426
65427
7424
My output:

Code: Select all

299998
-299998
0
58003

Posted: Sat Sep 02, 2006 9:47 pm
by Ghust_omega
Hi!! Martin

you are right , I have a bug in my code, thanks for that

Thanks in advance
Keep posting.

Posted: Sun Sep 03, 2006 3:51 pm
by krijger
Note that the first integer in the input is the number of cases. The input description does not explicitely state this. Treating it as the 'n' of the first case (and reading input until EOF) gives the right answer for all example cases, but will get WA on the judge.

Posted: Tue Sep 05, 2006 8:28 pm
by lbfacci
krijger wrote:Note that the first integer in the input is the number of cases. The input description does not explicitely state this. Treating it as the 'n' of the first case (and reading input until EOF) gives the right answer for all example cases, but will get WA on the judge.
I took 2 WAs in the contest because of that! :roll:

Posted: Tue Sep 05, 2006 8:37 pm
by ayon
I faced the same problem at real-time contest held somedays ago at our country. I thought the first line of input is the n for the 1st test case and got two runtime error(might be array was indexed with negative number), we then requested a clarification about he 1st line of input, but we were not answered. i still cannot understand how can the 1st line be the number of test cases.

hmm

Posted: Wed Sep 06, 2006 5:31 am
by shahriar_manzoor
Hmm it is really an unfortunate situation, although the description is implicit none of the reviewers marked it wrong. And also the both interpretations resulting in correct format is unintensional. I personally thought well though the description is a bit implicit the sample makes it clear... but actually the sample confuses things a bit as I see it now.

Posted: Wed Sep 06, 2006 5:52 am
by Nazmul Quader Zinnuree
12 penalties !!!!!!!!!!!!

WA, TLE, RTE, RTE, WA, TLE, WA, ...........

in EWUIPC, the reason is simple as mentioned above. Killed our time, killed our head, killed our position, killed us..... But we got no clarifications, no corrections, but a potato sample, that was right in all ways.

However, the description should be changed, immediately.
:(

Re: 11078 - Open Credit System

Posted: Tue Feb 18, 2014 8:39 am
by uDebug
In addition to test cases shared by Martin Macko, here's some input / output that I found useful during testing / debugging.

Input:

Code: Select all

3
4
99
94
91
100
5
99
94
91
100
-99
6
98
200
90
60
50
100
AC Output:

Code: Select all

8
199
150

Re: 11078 - Open Credit System

Posted: Mon Nov 24, 2014 4:00 pm
by ehsanulbigboss
Didn't read the question carefully :oops:

Re: 11078 - Open Credit System

Posted: Tue Nov 25, 2014 5:53 am
by lighted
Input consists of a number of test cases T (less than 20). Each case starts with an integer n which is the number of students in the course. This value can be as large as 100,000 and as low as 2
Your code's complexity is 20 * O(n * n) = 20 * 100000 * 100000 = 2e+10. It will give TLE.

You can solve it in 20 * O(n) even without saving numbers in integer array. For each input number check and save current max value and max difference. Max value is necessary to calculate max difference. Then print max difference :)

Re: 11078 - Open Credit System

Posted: Sat Jul 11, 2015 2:35 pm
by mohdali231993

Code: Select all

#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int t,h,l,i,d,de,v;
    cin >> t;
    while(t--)
    { 
      cin >> i;de = i;
      h = -150000;l = 150000;d = -299998;
      while(i--)
      {
        //cout<<i<<endl;        
        cin >> v;
        if(v > h && i >= 0){
                h=v;l = 150000;//cout<<" h "<<h<<endl;
                }
        else if(v < l){
             l=v;//cout<<" l "<<l<<endl;
             if(d < (h-l)){
                  d = h-l;
                  }
             }
      }
      
      cout<<d<<endl;
    }
    //cin>>h;
    return 0;
}
i hv tried all above inputs
i m getting wa cant figure out why!

Re: 11078 - Open Credit System

Posted: Sat Jul 11, 2015 3:18 pm
by mohdali231993
Got it.
condition should be
i > 0