11078 - Open Credit System
Moderator: Board moderators
-
- Experienced poster
- Posts: 115
- Joined: Tue Apr 06, 2004 7:04 pm
- Location: Venezuela
11078 - Open Credit System
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
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
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
Re: 11078 WA
Yes, your approach is correct... You have a bug in your code probably...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
Try:
Code: Select all
4
2
149999
-149999
2
-149999
149999
2
47
47
7
32652
652
2642
642
-426
65427
7424
Code: Select all
299998
-299998
0
58003
-
- Experienced poster
- Posts: 115
- Joined: Tue Apr 06, 2004 7:04 pm
- Location: Venezuela
I took 2 WAs in the contest because of that!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.
-
- Experienced poster
- Posts: 161
- Joined: Tue Oct 25, 2005 8:38 pm
- Location: buet, dhaka, bangladesh
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
----------------
the world is nothing but a good program, and we are all some instances of the program
-
- System administrator & Problemsetter
- Posts: 399
- Joined: Sat Jan 12, 2002 2:00 am
hmm
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.
-
- New poster
- Posts: 42
- Joined: Sun Jul 31, 2005 2:07 am
- Location: SUST. Bangladesh
- Contact:
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.
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
In addition to test cases shared by Martin Macko, here's some input / output that I found useful during testing / debugging.
Input:
AC Output:
Input:
Code: Select all
3
4
99
94
91
100
5
99
94
91
100
-99
6
98
200
90
60
50
100
Code: Select all
8
199
150
-
- New poster
- Posts: 32
- Joined: Tue Jul 22, 2014 1:17 am
Re: 11078 - Open Credit System
Didn't read the question carefully
Last edited by ehsanulbigboss on Thu Feb 05, 2015 10:00 pm, edited 1 time in total.
Re: 11078 - Open Credit System
Your code's complexity is 20 * O(n * n) = 20 * 100000 * 100000 = 2e+10. It will give TLE.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
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
-
- New poster
- Posts: 11
- Joined: Sun Nov 09, 2014 6:46 pm
Re: 11078 - Open Credit System
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 m getting wa cant figure out why!
-
- New poster
- Posts: 11
- Joined: Sun Nov 09, 2014 6:46 pm
Re: 11078 - Open Credit System
Got it.
condition should be
i > 0
condition should be
i > 0