# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Name |
---|
I'm not a Java developer at all, but I found out the answer in less than 30 seconds. Try googling please, the first StackOverflow link answers your question thoroughly.
I do not use Kotlin for competitive programming, but I think the TLE is because of the fact that Array is a collection of "Int" data type while IntArray is "int" data type (read up on it, "Int" is a completely different data type than "int" in Kotlin). I don't know what causes the difference in performance though. I can be wrong. Perhaps a contestant who uses Kotlin can help. It seems interesting. Gotta say, that is one nasty error.
The difference between
int
andInt
in Kotlin is like between using primitiveint
andnew int
in C++. In a nutshell,Int
allocates the number on heap and stores the pointer to the number, whileint
stores just the number itself. That is also the reason why you (OP) are seeing that the TLE submission uses more memory.Yaa, makes sense thanks, actually I did searched bt just didn't thought such simple memory allocation would make code 6x slower, I thought it's some wierd collision that I'm not aware of.
Um........I am not the OP. What makes you say that? I do not use Kotlin, apart from android stuff. I do not use it for competitive programming......and for good reason. But yeah, perhaps you are right about why "Int" is slower. Also, this makes "Int" data type null-able, and yeah, Kotlin has a freakish way to deal with Nulls, although we android devs love it.
I did not mean you're the OP. I wanted to comment on your comment, not the post, because the first part of my comment is answering your question about 'I don't know what causes the difference in performance'. The last sentence is a conclusion and refers to the whole situation, hence commenting OP's submissions. If Codeforces UI allowed me to reply to both the comment and the post at once, I'd do that. Sadly we have a comment tree, not a comment DAG, so I had to choose where to reply.