問題一覧 > 通常問題

No.3468 A Certain Judge Server

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 67
作問者 : yuki2006
お気に入りにしたユーザー ProblemId : 1850 / 自分の提出
問題文最終更新日: 2026-03-06 22:17:55
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder 2026新ジャッジ contest (順位表) の他の問題:

Problem Statement

An online judge has multiple judge servers that process submitted programs in parallel. Here, we focus on one of those servers.

This server's queue contains $N$ programs. Program $i$ takes $T_i-0.1$ seconds to execute.

At time $0$, the server is idle.

$N$ "execution commands" are sent to this server at times $s_1 < s_2 < \cdots < s_N$. When the server receives an execution command, if it is idle, it takes the program at the front of the queue and starts executing it. If it is executing a program, the program at the front of the queue is passed on to another server.

When program $i$ starts executing at time $t$, it finishes at time $t + T_i-0.1$ and the server returns to the idle state.

Find the number of programs executed on this server.

Input

$N$
$T_1\ T_2\ \ldots\ T_N$
$s_1\ s_2\ \ldots\ s_N$

Output

Output the number of programs executed on this server in 1 line.

Print a newline at the end.

Constraints

All constraints are integers.
  • $1 \le N \le 1000$
  • $1 \le T_i \le 10^9$
  • $1 \le s_1 < s_2 < \cdots < s_N \le 10^9$

Sample

Sample 1
Input
3
2 3 1
1 4 6
Output
2

Time 1: Idle → starts executing program 1 (T=2, finishes at time 2.9)
Time 4: Idle → starts executing program 2 (T=3, finishes at time 6.9)
Time 6: Executing → program 3 is passed on to another server

Sample 2
Input
5
1 2 3 4 1
1 2 4 5 8
Output
4

Time 1: Idle → starts executing program 1 (T=1, finishes at time 1.9)
Time 2: Idle → starts executing program 2 (T=2, finishes at time 3.9)
Time 4: Idle → starts executing program 3 (T=3, finishes at time 6.9)
Time 5: Executing → program 4 is passed on to another server
Time 8: Idle → starts executing program 5 (T=1, finishes at time 8.9)

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。