On the task Moondance, I got this problem to solve. I wrote this piece of code.
function solve(input: string) -> string {
let as = [from a in input.split("\n") select string(a)];
let ans: string[] = [];
let t = int(as[0]);
let p2 = [1];
let q = 1;
for (let i = 1; i <= 1000000; i += 1) {
q = q * 2 % 1000000007;
p2.push(q);
}
for (let i = 1; i <= t; i += 1) {
let n = int(as[i]);
let res = n + 1;
if (n == 1) {
res = 1;
} else {
res = res * p2[n - 2] % 1000000007;
}
ans.push("Case " + string(i) + ": " + string(res));
}
return ans.join("\n") + "\n";
}
After executing it, I found it always gets "[9,7] Execution cost exceeded". However, after I tried submitting it, it got Accepted.
crowdforces
Why are you Posting again?
?
On NEARCrowd itself code transpiles to JavaScript, but when you submit it, it transpiles to C++. Execution cost exceeds just because JS is relatively slow, it doesn't always means that code will give TL or ML in OJ.