<https://codingcompetitions.withgoogle.com/kicksta...
# announcements
f
https://codingcompetitions.withgoogle.com/kickstart/round/000000000019ffc7/00000000001d3f56 i was trying to solve this using kotlin my code passes the test cases but after submission it doesn't get accepted (same algo is accepted for c++ code ) please help
a
Seems to be passed for me, can you show your attempt?
The following code passes easily:
f
fun main(){ fun readLn() = readLine()!! // string line fun readInt() = readLn().toInt() // single int fun readStrings() = readLn().split(" ") // list of strings fun readInts() = readStrings().map { it.toInt() } //list of ints val t = readInt() for(testcase in 1..t){ val (n,b) = readInts() val a = readInts().sorted() var sum = 0 for(i in 0..n-1){ sum+=a[i] if(sum>b){ println("Case #$testcase: $i") break } } } }
can you tell me whats the problem in my code
a
The
$i
seems to be 1 less than the answer.
f
what shall i change
a
Code seems fine, did you got Time Limit exceeded?
f
no it's test case skipped
image.png
a
You attempt fail to give an output for:
Copy code
1
5 200
2 3 4 5 6
i.e. when you are able to buy all the houses ­čÖé
f
understood thanks a lot
­čĹŹ 1