0% found this document useful (0 votes)
3 views

Problem - C - Codeforces

The document describes a problem from the Codeforces contest where Cirno can perform two operations on a sequence to maximize the sum of its elements. The operations include reversing the sequence and replacing it with its difference sequence. The input consists of multiple test cases, and the output is the maximum possible sum for each case.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Problem - C - Codeforces

The document describes a problem from the Codeforces contest where Cirno can perform two operations on a sequence to maximize the sum of its elements. The operations include reversing the sequence and replacing it with its difference sequence. The input consists of multiple test cases, and the output is the maximum possible sum for each case.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

3/9/25, 10:21 PM Problem - C - Codeforces

Enter | Register

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

 Codeforces Blitz Cup 2025 Final Rounds Have Started! Join the stream now: https://youtu.be/rbHFLNg7Nkc. ×

PROBLEMS SUBMIT CODE MY SUBMISSIONS STATUS HACKS ROOM STANDINGS CUSTOM INVOCATION

Ethflow Round 1 (Codeforces


C. Cirno and Operations Round 1001, Div. 1 + Div. 2)

time limit per test: 2 seconds Finished


memory limit per test: 512 megabytes
→ Practice?
Cirno has a sequence a of length n. She can perform either of the following two operations for any
(possibly, zero) times unless the current length of a is 1: Want to solve the contest problems after the
official contest ends? Just register for
practice and you will be able to submit
Reverse the sequence. Formally, [a1 , a2 , … , an ] becomes [an , an−1 , … , a1 ] after the operation. solutions.
Replace the sequence with its difference sequence. Formally, [a1 , a2 , … , an ] becomes
Register for practice
[a2 − a1 , a3 − a2 , … , an − an−1 ] after the operation.

Find the maximum possible sum of elements of a after all operations.


→ Virtual participation 
Input
Virtual contest is a way to take part in past
The first line of input contains a single integer t (1 ≤ t ≤ 100 ) — the number of input test cases.
contest, as close as possible to participation
on time. It is supported only ICPC mode for
The first line of each test case contains a single integer n (1 ≤ n ≤ 50 ) — the length of sequence a. virtual contests. If you've seen these
problems, a virtual contest is not for you -
solve these problems in the archive. If you
The second line of each test case contains n integers a1 , a2 , … , an (|ai | ≤ 1000 ) — the sequence a. just want to solve some problem from a
contest, a virtual contest is not for you -
Output solve this problem in the archive. Never use
someone else's code, read the tutorials or
For each test case, print an integer representing the maximum possible sum. communicate with other person during a
virtual contest.
Example
Start virtual contest
input Copy

https://codeforces.com/contest/2062/problem/C 1/2
3/9/25, 10:21 PM Problem - C - Codeforces

5 → Problem tags
1
-1000
brute force math *1200
2
5 -3 No tag edit access
2
1000 1
9 → Contest materials
9 7 9 -9 9 -8 7 -8 9
11 Announcement (en)
678 201 340 444 453 922 128 987 127 752 0
Tutorial (en)
output Copy

-1000
8
1001
2056
269891
Note
In the first test case, Cirno can not perform any operation, so the answer is −1000 .

In the second test case, Cirno firstly reverses the sequence, then replaces the sequence with its
difference sequence: [5, −3] → [−3, 5] → [8]. It can be proven that this maximizes the sum, so the
answer is 8.

In the third test case, Cirno can choose not to operate, so the answer is 1001 .

Codeforces (c) Copyright 2010-2025 Mike Mirzayanov


The only programming contests Web 2.0 platform
Server time: Mar/09/2025 22:21:46UTC+7 (l2).
Desktop version, switch to mobile version.
Privacy Policy

Supported by

https://codeforces.com/contest/2062/problem/C 2/2

You might also like