QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 100 قابلة للهجوم ✓

#4215. Najprostsza suma

الإحصائيات

Funkcja $f(a_1, a_2, \dots, a_n)$ oznacza największą sumę elementów niepustego podciągu spójnego w tablicy $a_1, a_2, \dots, a_n$.

Dana jest tablica $a_1, a_2, \dots, a_n$. Możesz wydać jedną monetę, aby zmniejszyć dowolny element tablicy $a$ o 1. Inna funkcja, $g(k)$, reprezentuje najmniejszą wartość $f(a_1, a_2, \dots, a_n)$, jaką można osiągnąć, wydając co najwyżej $k$ monet.

Oblicz $g(1) + g(2) + \dots + g(k)$. Ponieważ ta wartość może być bardzo duża, oblicz ją modulo $998\,244\,353$.

Wejście

Pierwsza linia wejścia zawiera jedną liczbę całkowitą $n$ ($1 \le n \le 100\,000$): liczbę elementów w tablicy $a$. Druga linia zawiera $n$ liczb całkowitych $a_1, a_2, \dots, a_n$ ($-10^8 \le a_i \le 10^8$). Trzecia linia zawiera jedną liczbę całkowitą $k$ ($1 \le k \le 10^{13}$).

Wyjście

Wypisz $g(1) + g(2) + \dots + g(k)$ modulo $998\,244\,353$.

Przykład

Wejście 1

5
1 -1 2 -2 3
3

Wyjście 1

5

Wejście 2

3
-3 -5 -35
1

Wyjście 2

998244349

Uwagi

W pierwszym przykładzie $g(1) = 2, g(2) = 2, g(3) = 1$. W drugim przykładzie $g(1) = -4$.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#1011EditorialOpen题解Qiuly2026-02-14 01:41:10View

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.