estie プログラミングコンテスト2025 (AtCoder Regular Contest 210)
E
Subset Sum Gaps
AtCoder
⌀ 2957
原题
← DF →
翻译中…

Problem Statement

翻译中…

You are given a sequence of positive integers $A=(A_1,A_2,\ldots,A_N)$.

翻译中…

There are $2^N$ subsequences of $A$ when distinguishing subsequences by the indices of their elements. Let $S_1, S_2, \ldots, S_{2^N}$ be the sums of these subsequences, enumerated in ascending order.

翻译中…

For all integers $k$ ($1\leq k\leq 2^N-1$) that satisfy $1.01 \times S_k\leq S_{k+1}$, output $S_k, S_{k+1}, (k\bmod 998244353)$.

翻译中…

What is a subsequence A subsequence of a sequence $A$ is a sequence obtained by removing zero or more elements from $A$ and arranging the remaining elements in their original order.

翻译中…

Constraints

翻译中…
  • $2\leq N\leq 5000$
  • $1\leq A_i\leq 10^{13}$
翻译中…

Input

翻译中…

The input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 \ldots A_N

翻译中…

Output

翻译中…

On the first line, output the number of integers $k$ that satisfy the condition.

翻译中…

From the second line onwards, for each integer $k$ that satisfies the condition, output $S_k, S_{k+1}, (k\bmod 998244353)$ separated by spaces on each line.

翻译中…

Output in ascending order of $k$.

翻译中…

样例

Input #1
3
5 5 3
Output #1
5
0 3 1
3 5 2
5 8 4
8 10 6
10 13 7
We have the following eight subsequences: - The empty subsequence. The sum is $0$. - $(5)$. The sum is $5$. This subsequence appears twice. - $(3)$. The sum is $3$. - $(5,5)$. The sum is $10$. - $(5,3)$. The sum is $8$. This subsequence appears twice. - $(5,5,3)$. The sum is $13$. $S_1, S_2, \ldots, S_8$ are $0,3,5,5,8,8,10,13$ in order.
Input #2
2
100 101
Output #2
3
0 100 1
100 101 2
101 201 3
Input #3
2
101 102
Output #3
2
0 101 1
102 203 3
Input #4
20
456 206 448 830 937 793 483 527 772 239 361 925 364 956 355 420 557 739 323 912
Output #4
23
0 206 1
206 239 2
239 323 3
323 355 4
355 361 5
364 420 7
420 445 8
448 456 10
456 483 11
483 527 12
529 557 14
570 594 19
594 600 20
603 626 22
626 654 23
662 678 26
695 716 32
725 733 36
743 763 39
784 793 48
820 830 60
850 865 65
11397 11603 1048575
题目信息
题号
arc210_e
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。