結果
| 問題 |
No.3325 陰陽師
|
| コンテスト | |
| ユーザー |
高橋ゆに
|
| 提出日時 | 2025-07-13 00:46:46 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,417 bytes |
| コンパイル時間 | 184 ms |
| コンパイル使用メモリ | 82,240 KB |
| 実行使用メモリ | 67,284 KB |
| 最終ジャッジ日時 | 2025-11-01 02:53:01 |
| 合計ジャッジ時間 | 3,883 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 30 |
ソースコード
N = int(input())
T = list(map(int, input().split()))
L = list(map(int, input().split()))
T.sort(reverse = True)
L.sort(reverse = True)
SKIPPED = 1
BEST_TIMES =[[-1] * N for _ in (not SKIPPED, SKIPPED)]
TOO_LONG = [False] * N
def search_best_times(skipped):
pre_problem_i = -1
for music_i, time_limit in enumerate(L):
if skipped and music_i == 0:
continue
for problem_i in range(pre_problem_i + 1, N):
solve_time = T[problem_i]
if solve_time < (T[music_i] if TOO_LONG[music_i] else time_limit):
BEST_TIMES[skipped][music_i] = solve_time
pre_problem_i = problem_i
if music_i == problem_i:
TOO_LONG[music_i] = True
break
search_best_times(not SKIPPED)
search_best_times(SKIPPED)
def main():
dp = [0, T[0] if TOO_LONG[0] else L[0]]
for music_i, time_limit in enumerate(L):
if BEST_TIMES[SKIPPED][music_i] > -1:
dp[SKIPPED] += BEST_TIMES[SKIPPED][music_i]
if music_i > 0 and not TOO_LONG[music_i] and BEST_TIMES[not SKIPPED][music_i] > -1:
dp[SKIPPED] = max(dp[SKIPPED], dp[not SKIPPED] + time_limit)
if BEST_TIMES[not SKIPPED][music_i] > -1:
dp[not SKIPPED] += BEST_TIMES[not SKIPPED][music_i]
ans = max(dp)
print(ans)
if __name__ == "__main__":
main()
高橋ゆに