编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#3026 | #1004. 提瓦特大冒险 | Compile Error | 0 | 0 ms | 0 K | Python 3 / 1.1 K | Met | 2023-11-22 21:59:05 |
import java.util.HashMap;
public class Traveler {
public static boolean canReachLastRoom(int N, int timeLimit, int[] travelTimes, HashMap<Integer, Integer> rewardRooms) {
int currentTime = timeLimit;
for (int i = 0; i < N - 1; ++i) {
// Move to the next room
currentTime -= travelTimes[i];
// Check if there is a reward in the current room
if (rewardRooms.containsKey(i + 1)) {
currentTime += rewardRooms.get(i + 1);
}
// If the remaining time is not enough to reach the next room, return false
if (currentTime <= 0) {
return false;
}
}
return true;
}
public static void main(String[] args) {
int N = 5;
int timeLimit = 10;
int[] travelTimes = {2, 3, 1, 2};
HashMap<Integer, Integer> rewardRooms = new HashMap<>();
rewardRooms.put(2, 5);
rewardRooms.put(4, 3);
boolean result = canReachLastRoom(N, timeLimit, travelTimes, rewardRooms);
System.out.println(result);
}
}
编译信息
Traceback (most recent call last):
File "/usr/lib/python3.8/py_compile.py", line 144, in compile
code = loader.source_to_code(source_bytes, dfile or file,
File "<frozen importlib._bootstrap_external>", line 846, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "a.py", line 3
public class Traveler {
^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/py_compile.py", line 209, in main
compile(filename, doraise=True)
File "/usr/lib/python3.8/py_compile.py", line 150, in compile
raise py_exc
__main__.PyCompileError: File "a.py", line 3
public class Traveler {
^
SyntaxError: invalid syntax
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/lib/python3.8/py_compile.py", line 218, in <module>
sys.exit(main())
File "/usr/lib/python3.8/py_compile.py", line 213, in main
if quiet < 2:
NameError: name 'quiet' is not defined