Sequence Transform Operations
Transform one integer sequence into another with pair operations when possible.
Sequence Transform Operations
This is an Agentics migration of Frontier-CS algorithmic problem 247.
Your submitted zip_project run command is executed once per case. It receives exactly one case on stdin and must write the candidate answer to stdout. Do not read or write challenge-owned files. Network access is unavailable during setup, build, and run.
The trusted separated evaluator uses the original Frontier-CS Testlib checker. Public validation is intentionally small and only checks the interface. Official scoring uses the private Frontier-CS-derived run manifest.
Original Statement
Problem Statement
You are given two integer sequences of length $N$: $A=(A_1, A_2, \dots, A_N)$ and $B=(B_1, B_2, \dots, B_N)$.
You may perform operations of the following kind:
- Choose a pair of integers $(i, j)$ with $1 \le i < j \le N$.
- Replace $A_i$ with $A_j - 1$ and $A_j$ with $A_i + 1$.
Your goal is to make $A = B$ using the minimum number of operations. Determine whether the goal is achievable. If it is, output a sequence of operations with the minimum length that achieves it.
Constraints
- $2 \le N \le 100$
- $1 \le A_i, B_i \le 100$
- All values in input are integers.
Input
The input is given from Standard Input in the following format:
N
A1 A2 ... AN
B1 B2 ... BN
Output
If it is possible to make $A = B$, output Yes;
otherwise, output No.
If you output Yes, also output an operation sequence in the following format:
M
i_1 j_1
i_2 j_2
...
i_M j_M
Example 1
Input:
4
2 2 1 4
3 2 2 2
Output:
Yes
2
1 4
3 4
Example 2
Input:
6
5 4 4 3 4 2
5 1 2 3 4 1
Output:
No
Example 3
Input:
7
2 4 2 4 3 2 5
5 4 3 2 5 1 2
Output:
Yes
18
5 7
1 7
2 4
1 5
1 5
1 4
4 5
4 5
3 4
5 7
1 5
1 7
1 6
6 7
1 7
2 4
2 5
4 5
Scoring:
Your score is calculated based on the number of operations $m$, and $m_0$(number of operations by std):
if $m \leq m_0$, you receive full score (1.0).
if $m>2 * m_0$, you receive 0 score.
otherwise Score = $(2 * m_0 - m) / (m_0)$, linearly decreasing from 1.0 to 0.0.
Time limit:
2 seconds
Memory limit:
512 MB
Configuration
Metrics
Latest Submissions
View all →Nothing here yet
Top Rankings
View all →Nothing here yet