№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Название |
---|
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.