9/2/25, 10:28 AM Problem - 2065C1 - Codeforces
|
stdfloat | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
PROBLEMS SUBMIT STATUS STANDINGS CUSTOM TEST
Codeforces Round 1003 (Div. 4)
C1. Skibidus and Fanum Tax (easy version) Finished
time limit per test: 2 seconds Practice
memory limit per test: 256 megabytes
This is the easy version of the problem. In this version, m = 1 .
Skibidus has obtained two arrays a and b, containing n and m elements respectively. For each integer i from 1 to → Virtual participation
n , he is allowed to perform the operation at most once:
Virtual contest is a way to take part in past contest,
as close as possible to participation on time. It is
Choose an integer j such that 1 ≤ j ≤ m . Set ai := bj − ai . Note that ai may become non-positive as a supported only ICPC mode for virtual contests. If
you've seen these problems, a virtual contest is not
result of this operation. for you - solve these problems in the archive. If you
just want to solve some problem from a contest, a
virtual contest is not for you - solve this problem in
Skibidus needs your help determining whether he can sort a in non-decreasing order∗ by performing the above the archive. Never use someone else's code, read
operation some number of times. the tutorials or communicate with other person
during a virtual contest.
∗
a is sorted in non-decreasing order if a1 ≤ a2 ≤ … ≤ an .
Start virtual contest
Input
4
The first line contains an integer t (1 ≤ t ≤ 10 ) — the number of test cases.
→ Clone Contest to Mashup
The first line of each test case contains two integers n and m (1 ≤ n ≤ 2 ⋅ 10
5
,m = 1 ).
9
The following line of each test case contains n integers a1 , a2 , … , an (1 ≤ ai ≤ 10 ). → Submit?
9
The following line of each test case contains m integers b1 , b2 , … , bm (1 ≤ bi ≤ 10 ).
Language: GNU G++20 13.2 (64 bit, winlibs)
It is guaranteed that the sum of n and the sum of m over all test cases does not exceed 2 ⋅ 10 . 5
Choose
Choose File No file chosen
file:
Output
For each test case, if it is possible to sort a in non-decreasing order, print "YES" on a new line. Otherwise, print "NO" Submit
on a new line.
You can output the answer in any case. For example, the strings "yEs", "yes", and "Yes" will also be recognized → Contest materials
as positive responses.
Announcement (en)
Example
Video Tutorial (en)
input Copy
Tutorial #2 (en)
5
1 1
5
9 → CF GetRating
3 1
1 4 3 *1100
3
4 1 Show All Tags
1 4 2 5
6 Contest Standings
4 1
5 4 10 5
4
3 1
9 8 7
8
output Copy
YES
NO
YES
NO
YES
Note
In the first test case, [5] is already sorted.
In the second test case, it can be shown that it is impossible.
In the third test case, we can set a3 := b1 − a3 = 6 − 2 = 4 . The sequence [1, 4, 4, 5] is in nondecreasing
order.
In the last case, we can apply operations on each index. The sequence becomes [−1, 0, 1], which is in
nondecreasing order.
Codeforces (c) Copyright 2010-2025 Mike Mirzayanov
The only programming contests Web 2.0 platform
https://codeforces.com/problemset/problem/2065/C1 1/2
9/2/25, 10:28 AM Problem - 2065C1 - Codeforces
Server time: Sep/02/2025 10:27:34UTC+5 (h1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions
Supported by
https://codeforces.com/problemset/problem/2065/C1 2/2