Your program took more time than expected.Time Limit Exceeded Expected Time Limit < 3.496sec Hint : Please optimize your code and submit again.
为什么Time Limit Exceeded
会出现?我该如何解决这个问题?
注意当我在这里运行代码时,一切正常。但是当我单击此处的Submit
按钮时,它显示以下错误:
Your program took more time than expected.Time Limit Exceeded Expected Time Limit < 3.496sec Hint : Please optimize your code and submit again.
谢谢。
我的代码是
int testCases = int.Parse(Console.ReadLine().Trim());
while (testCases-- > 0)
{
int arrSize = int.Parse(Console.ReadLine().Trim());
string[] arr = Console.ReadLine().Trim().Split(' ');
for (int i = 0; i < arrSize - 1; i++)
{
if (int.Parse(arr[i]) > int.Parse(arr[i + 1]))
{
Console.Write(arr[i + 1] + " ");
}
else
Console.Write("-1" + " ");
}
Console.Write("-1");
Console.WriteLine();
}
慕后森
相关分类