0% found this document useful (0 votes)
2 views2 pages

Problem - A - Codeforces

The document describes a problem from Codeforces Round 1112 (Div. 2) involving a magical machine with plots containing balls of varying weights. The goal is to determine if there exists a perfect parameter k such that after a movement operation, each plot contains exactly one ball without causing the machine to explode. The input consists of multiple test cases, each specifying the number of balls and their weights, with the output indicating 'YES' or 'NO' for each test case based on the existence of a perfect parameter.

Uploaded by

xilaber296
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Problem - A - Codeforces

The document describes a problem from Codeforces Round 1112 (Div. 2) involving a magical machine with plots containing balls of varying weights. The goal is to determine if there exists a perfect parameter k such that after a movement operation, each plot contains exactly one ball without causing the machine to explode. The input consists of multiple test cases, each specifying the number of balls and their weights, with the output indicating 'YES' or 'NO' for each test case based on the existence of a perfect parameter.

Uploaded by

xilaber296
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

7/26/26, 8:11 PM Problem - A - Codeforces

dhakshin2410 | Logout

HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP

PROBLEMS SUBMIT CODE MY SUBMISSIONS STATUS HACKS ROOM STANDINGS CUSTOM INVOCATION

Codeforces Round 1112 (Div. 2)


A. Threshold Movement Contest is running
time limit per test: 1 second
02:23:08
memory limit per test: 256 megabytes
Contestant
There are (n + 2) plots in a magical machine, numbered from 0 to (n + 1) . Initially, plot i
contains a ball of weight wi for each 1 ≤ i ≤ n . Plot 0 and plot (n + 1) is empty.

You can input an integer parameter k to the machine. After that, the machine will perform the
following movement operation simultaneously for every 1 ≤ i ≤ n : → Submit?

If wi < k , the ball at plot i will move left to plot (i − 1); Language: GNU G++17 7.3.0
If wi > k , the ball at plot i will move right to plot (i + 1);
Choose
If wi = k, however, the machine will explode immediately.
file:
Choose File No file chosen

Be careful: there is 50 points penalty for


A parameter k is called perfect if and only if, after performing the movement operation, the submission which fails the pretests or
machine does not explode, and plot i contains exactly one ball for each 1 ≤ i ≤ n . resubmission (except failure on the first test,
denial of judgement or similar verdicts).
"Passed pretests" submission verdict doesn't
Determine whether there exists a perfect parameter. guarantee that the solution is absolutely
correct and it will pass system tests.
Note that the parameter k must be an integer.
Submit
Input
Each test contains multiple test cases. The first line contains the number of test cases t (
1 ≤ t ≤ 500 ). The description of the test cases follows.
→ Score table
The first line of each test case contains a single integer n (1 ≤ n ≤ 100 ) — the number of Score
balls. Problem A 500

The second line of contains n integers w1 , w2 , … , wn (1 ≤ wi ≤ 10


9
) — the weights of Problem B 750
each ball. Problem C 1500
Problem D 2000
Output
For each test case, print "YES" if there exists a perfect parameter, and "NO" otherwise. Problem E 2500
Problem F 3000
You can output the answer in any case (upper or lower). For example, the strings "yEs",
Successful hack 100
"yes", "Yes", and "YES" will be recognized as positive responses.
Unsuccessful hack -50
Example
Unsuccessful submission -50
input Copy
Resubmission -50
6 * If you solve problem on 00:00 from the first attempt
1
7
4
9 1 8 2
4
5 4 7 1
6
6 1 7 2 8 3
6
1 10 2 9 3 8
8
20 1 19 2 18 3 17 4

output Copy

NO
YES
NO
YES
NO
YES
CF+
Note
In the first test case:

[Link] 1/2
7/26/26, 8:11 PM Problem - A - Codeforces
If k ≤ 6, the only ball will move to plot 0. Since plot 1 contains no balls, k is not a perfect
parameter;
If k ≥ 8, the only ball will move to plot 2. Since plot 1 contains no balls, k is not a perfect
parameter;
If k = 7, the machine will explode immediately, and k is not a perfect parameter.

Thus, there does not exist a perfect parameter.

In the second test case, we can choose k = 5 :

w1 = 9 > k , so the ball at plot 1 will move to plot 2;


w2 = 1 < k , so the ball at plot 2 will move to plot 1;
w3 = 7 > k , so the ball at plot 3 will move to plot 4;
w4 = 2 < k , so the ball at plot 4 will move to plot 3.

Plot 1, 2, 3, and 4 all contain exactly one ball after the movement operation, so k = 5 is a
perfect parameter. Note that k = 3, 4, or 6 is also a perfect parameter.

Codeforces (c) Copyright 2010-2026 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Jul/26/2026 20:05:10UTC+5.5 (h1).
Desktop version, switch to mobile version.
Privacy Policy | Terms and Conditions

Supported by

[Link] 2/2

You might also like