![](/style/images/good.png)
![](/style/images/bad.png)
Very Peculiar Problem in Think Cell Round 1 A
source link: https://codeforces.com/blog/entry/126870
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
So this was the question 1930A - Maximise The Score at think-cell Round 1. We simply had to sort the array and add the odd entries.
And so I did except that it gets accepted or TLE rejected just cause of Variable name.
I chose the loop variable i here and it TLEd 250123631 I chose the loop variable j and the exact same code as above and it got accepted 250123236 There are two loops in my program and I named both as j and it still got accepted 250123505
So why the particular hate for "i"? satyam343 And I lost 15 extra minutes and valuable points in that question as well.
I would love to know the reason if someone could explain or if it is a CF issue.
32 hours ago, # | |
-
Java programs usually take that much time and I don't know much about the internal working of CF but I think they alot more time for different languages. I've never faced a problem before because of Java and to face one in something so trivial is this doesn't make sense. And why the variable name change works then. Same code for different people with different results don't make sense to me
-
Time limit is same for any language you choose.
If they keep constraints loose:
- C++ users will be at advantage as their unoptimized solutions might get accepted.
If they keep constraints tight:
- Other languages will be at disadvantage as their optimized solutions might not get accepted.
Therefore they tend to find a middle ground. In this case constraints were tight.
250166204 This C++ submission I made got accepted in 639 ms.So why the particular hate for "i"?
Now you must've understood that variable names don't matter.
-
-
Java's
Scanner
is known to be very slow for large inputs. All the solutions usingScanner
for the problem you mentioned took > ~900ms, and I think most of the running time of those solutions is consumed just for parsing inputs.Some participants have custom input parsers, which can reduce the running time to ~300ms. I think all Java coders should use them in CF -- I assume they are equivalents of C++'s
ios::sync_with_stdio(false)
andcin.tie(nullptr)
.
29 hours ago, # | First, It's not the variable name that changes the time it takes. It changes because in the for loop that you made with i you wrote i < 2*n, so you make the multiplication again in every iteration, but in the AC code, you put j < array.length. That's the difference in between AC and TLE. And your code may be slower than you think because, as far as I am concerned, Anyways, you still had bad luck |
-
I've used j variable here with the constraint as 2*n abs it still got accepted. 250123363. It's definitely because of the loop variable I believe. And arrays.sort uses merge sort so the complexity is nlog(n) for sure. Anything else you may think could be the reason for it?
-
for primitives if you use Arrays.sort(), it has worst case time complexity of 0(n^2), as it uses quick sort, to avoid that either create arrays using Objects from Wrapper Class or use Collections.sort(), they both use merge sort and are guaranteed to work in 0(nlogn). And use fast I/O in your template :)
-
22 hours ago, # | add special tl |
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK