What is the default timelimit for Golang? Is it the same as C, C++ or some relaxation is provided as in Python or Java ?
The reason being I tried to code the solution for problem CNOTE in March Challenge in Golang using O(n) complexity and I got TLE for some cases. The same logic was used for my C solution that easily passes the time limit.
My solution is CodeChef: Practical coding for everyone
According to the updated official codechef blog, the time limits are as given below.
Java – 2X
Python – 5X
Ruby – 3X
PHP – 3X
Lisp clisp – 3X
Lisp sbcl – 3X
Scala – 2X
C# – 2X
All other languages – 1X
Here X stands for the time limit states in the problem page itself.
So " go language " falls under 1X category
For more details visit this link.
hi @technophyle , if you are still looking for solution this code gets AC on all test cases
package main
import (
"fmt"
"os"
"bufio"
"strings"
"strconv"
)
var scr = bufio.NewReader(os.Stdin)
var ocr = bufio.NewWriter(os.Stdout)
func readInts() []int {
arr := make([]int, 0)
tmp, _ := scr.ReadString('\n')
tmp = strings.TrimRight(tmp, "\r\n")
for _, s := range strings.Split(tmp, " ") {
i, _ := strconv.Atoi(s)
arr = append(arr, i)
}
return arr
}
func main() {
var t, x, y, k, n, p, c int
defer ocr.Flush()
fmt.Fscanf(scr, "%d\n", &t)
for i := 1; i <= t; i++ {
// fmt.Fscanf(scr, "%d %d %d %d\n", &x, &y, &k, &n);
arr := readInts()
x, y, k, n = arr[0], arr[1], arr[2], arr[3]
flag := false
for j := 1; j <= n; j++ {
// fmt.Fscanf(scr, "%d %d\n", &p, &c)
arr = readInts()
p, c = arr[0], arr[1]
if x - y <= p && k >= c {
flag = true
}
}
if flag {
fmt.Fprintln(ocr, "LuckyChef")
// ocr.Flush()
} else {
fmt.Fprintln(ocr, "UnluckyChef")
//ocr.Flush()
}
}
}