11078 - Open Credit System

All about problems in Volume 110. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Ghust_omega
Experienced poster
Posts: 115
Joined: Tue Apr 06, 2004 7:04 pm
Location: Venezuela

11078 - Open Credit System

Post 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
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: 11078 WA

Post 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
Ghust_omega
Experienced poster
Posts: 115
Joined: Tue Apr 06, 2004 7:04 pm
Location: Venezuela

Post by Ghust_omega »

Hi!! Martin

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

Thanks in advance
Keep posting.
krijger
New poster
Posts: 39
Joined: Wed Jul 21, 2004 12:35 am

Post 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.
lbfacci
New poster
Posts: 4
Joined: Wed Nov 02, 2005 7:28 pm

Post 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:
ayon
Experienced poster
Posts: 161
Joined: Tue Oct 25, 2005 8:38 pm
Location: buet, dhaka, bangladesh

Post 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.
ishtiak zaman
----------------
the world is nothing but a good program, and we are all some instances of the program
shahriar_manzoor
System administrator & Problemsetter
Posts: 399
Joined: Sat Jan 12, 2002 2:00 am

hmm

Post 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.
Nazmul Quader Zinnuree
New poster
Posts: 42
Joined: Sun Jul 31, 2005 2:07 am
Location: SUST. Bangladesh
Contact:

Post 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.
:(
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 11078 - Open Credit System

Post 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
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
ehsanulbigboss
New poster
Posts: 32
Joined: Tue Jul 22, 2014 1:17 am

Re: 11078 - Open Credit System

Post by ehsanulbigboss »

Didn't read the question carefully :oops:
Last edited by ehsanulbigboss on Thu Feb 05, 2015 10:00 pm, edited 1 time in total.
lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11078 - Open Credit System

Post 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 :)
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman
mohdali231993
New poster
Posts: 11
Joined: Sun Nov 09, 2014 6:46 pm

Re: 11078 - Open Credit System

Post 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!
mohdali231993
New poster
Posts: 11
Joined: Sun Nov 09, 2014 6:46 pm

Re: 11078 - Open Credit System

Post by mohdali231993 »

Got it.
condition should be
i > 0
Post Reply

Return to “Volume 110 (11000-11099)”