E. Wrong Answer
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Consider the following problem: given an array aa containing nn integers (indexed from 00 to n−1n−1), find max0≤l≤r≤n−1∑l≤i≤r(r−l+1)⋅aimax0≤l≤r≤n−1∑l≤i≤r(r−l+1)⋅ai. In this problem, 1≤n≤20001≤n≤2000 and |ai|≤106|ai|≤106.

In an attempt to solve the problem described, Alice quickly came up with a blazing-fast greedy algorithm and coded it. Her implementation in pseudocode is as follows:

function find_answer(n, a)
# Assumes n is an integer between 1 and 2000, inclusive
# Assumes a is a list containing n integers: a[0], a[1], ..., a[n-1]
res = 0
cur = 0
k = -1
for i = 0 to i = n-1
cur = cur + a[i]
if cur < 0
cur = 0
k = i
res = max(res, (i-k)*cur)
return res

Also, as you can see, Alice's idea is not entirely correct. For example, suppose n=4n=4 and a=[6,−8,7,−42]a=[6,−8,7,−42]. Then, find_answer(n, a) would return 77, but the correct answer is 3⋅(6−8+7)=153⋅(6−8+7)=15.

You told Alice that her solution is incorrect, but she did not believe what you said.

Given an integer kk, you are to find any sequence aa of nn integers such that the correct answer and the answer produced by Alice's algorithm differ by exactly kk. Note that although the choice of nn and the content of the sequence is yours, you must still follow the constraints earlier given: that 1≤n≤20001≤n≤2000 and that the absolute value of each element does not exceed 106106. If there is no such sequence, determine so.

Input

The first and only line contains one integer kk (1≤k≤1091≤k≤109).

Output

If there is no sought sequence, print "-1".

Otherwise, in the first line, print one integer nn (1≤n≤20001≤n≤2000), denoting the number of elements in the sequence.

Then, in the second line, print nn space-separated integers: a0,a1,…,an−1a0,a1,…,an−1 (|ai|≤106|ai|≤106).

Examples
input

Copy
8
output

Copy
4
6 -8 7 -42
input

Copy
612
output

Copy
7
30 -12 -99 123 -2 245 -300
Note

The first sample corresponds to the example given in the problem statement.

In the second sample, one answer is n=7n=7 with a=[30,−12,−99,123,−2,245,−300]a=[30,−12,−99,123,−2,245,−300], in which case find_answer(n, a)returns 10981098, while the correct answer is 17101710.

E. Wrong Answer的更多相关文章

  1. SPOJ GSS3 Can you answer these queries III[线段树]

    SPOJ - GSS3 Can you answer these queries III Description You are given a sequence A of N (N <= 50 ...

  2. Stack Overflow is a question and answer site

    http://stackoverflow.com/ _ Stack Overflow is a question and answer site for professional and enthus ...

  3. SPOJ GSS2 Can you answer these queries II

    Time Limit: 1000MS   Memory Limit: 1572864KB   64bit IO Format: %lld & %llu Description Being a ...

  4. Question and Answer

    1.VS2013使用EntityFrame问题解决办法 解决办法参照博客http://pinter.org/?p=2374 使用到EntityFrame的项目配置文件修改如下: 项目中凡是使用到DbC ...

  5. 转 https://www.zhihu.com/question/27606493/answer/37447829

    著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处.作者:梁川链接:https://www.zhihu.com/question/27606493/answer/37447829来源: ...

  6. hdu 4027 Can you answer these queries?

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4027 Can you answer these queries? Description Proble ...

  7. GSS4 2713. Can you answer these queries IV 线段树

    GSS7 Can you answer these queries IV 题目:给出一个数列,原数列和值不超过1e18,有两种操作: 0 x y:修改区间[x,y]所有数开方后向下调整至最近的整数 1 ...

  8. GSS7 spoj 6779. Can you answer these queries VII 树链剖分+线段树

    GSS7Can you answer these queries VII 给出一棵树,树的节点有权值,有两种操作: 1.询问节点x,y的路径上最大子段和,可以为空 2.把节点x,y的路径上所有节点的权 ...

  9. GSS6 4487. Can you answer these queries VI splay

    GSS6 Can you answer these queries VI 给出一个数列,有以下四种操作: I x y: 在位置x插入y.D x  : 删除位置x上的元素.R x y: 把位置x用y取替 ...

  10. GSS5 spoj 2916. Can you answer these queries V 线段树

    gss5 Can you answer these queries V 给出数列a1...an,询问时给出: Query(x1,y1,x2,y2) = Max { A[i]+A[i+1]+...+A[ ...

随机推荐

  1. svn问题:在eclipse里面使用SVN,怎么实现版本回滚呢?

    共有4个答案 我要回答» JustForFly 回答于 2012-04-27 10:20 举报   想回到SVN服务器端的最新版本就使用 team->还原.. 想回到SVN服务器端的其它版本使用 ...

  2. 服务器开发入门——理解异步I/O

    对于服务器程序,I/O是制约系统性能最关键的因素.对于需要处理大量连接的高并发服务器程序,异步I/O几乎是不二的选择.Linux和Windows都为异步I/O构建了大量的基础设施.本文总结了一下Lin ...

  3. bzoj 2962 序列操作 —— 线段树

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2962 维护 sum[i] 表示选 i 个的乘积和,合并两个子树就枚举两边选多少,乘起来即可: ...

  4. bzoj4260 REBXOR——Trie树

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4260 对于每个位置,求一个前缀最大值和后缀最大值: 也就是从1到 i 的异或和要找前面某处的 ...

  5. hdu 3507(DP+斜率优化)

    Print Article Time Limit: 9000/3000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/Others)To ...

  6. mysql 联合2个列的数据 然后呈现出来

    SELECT a.voyageNum,CONCAT(a.startDate,'~',a.endDate) AS 日期  FROM tchw_voyageoilcost a ,tchw_voyageoi ...

  7. Spring--quartz中cronExpression配置说明

    Spring--quartz中cronExpression Java代码   字段      允许值         允许的特殊字符 秒       0-59        , - * / 分     ...

  8. Bootstrap标签页

    用法 您可以通过以下两种方式启用标签页: 通过 data 属性:您需要添加 data-toggle="tab" 或 data-toggle="pill" 到锚文 ...

  9. CollabNetSubversionEdge 4.0.4教程

    CollabNetSubversionEdge是svn的集成环境,集合subversion,apache,viewvc, 参考网址:http://blog.miniasp.com/post/2011/ ...

  10. ubuntu 12.04 alt+tab无法切换窗口的问题(转载)

    转自:http://www.2cto.com/os/201209/153282.html ubuntu 12.04 alt+tab无法切换窗口的问题   安装cpmpiz配置管理程序.   sudo ...