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. light oj 1032(数位DP)

    求一段区间中,每个十进制数所对应的二进制数中连续的1的个数之和. 设dp[i][0]代表长度为i的二进制数,首位为0,所含有的连续的1的个数之和. dp[i][1]代表长度为i的二进制数,首位为1,所 ...

  2. Velocity魔法堂系列一:入门示例(转)

    Velocity魔法堂系列一:入门示例 一.前言 Velocity作为历史悠久的模板引擎不单单可以替代JSP作为Java Web的服务端网页模板引擎,而且可以作为普通文本的模板引擎来增强服务端程序文本 ...

  3. Java多线程系列十——BlockingQueue

    参考资料:http://ifeve.com/java-synchronousqueue/http://www.cnblogs.com/jackyuj/archive/2010/11/24/188655 ...

  4. bzoj 3709: [PA2014]Bohater【贪心】

    先打能回血的,按消耗从小到大打: 然后按回血量降序打剩下的(把消耗和回血反着看就是上一种怪,打法一样): 中间体力小于0就输出无解 #include<iostream> #include& ...

  5. poj 3525Most Distant Point from the Sea【二分+半平面交】

    相当于多边形内最大圆,二分半径r,然后把每条边内收r,求是否有半平面交(即是否合法) #include<iostream> #include<cstdio> #include& ...

  6. 递推DP UVA 590 Always on the run

    题目传送门 题意:题意难懂,就是一个小偷在m天内从城市1飞到城市n最小花费,输入的是每个城市飞到其他城市的航班. 分析:dp[i][j] 表示小偷第i天在城市j的最小花费.状态转移方程:dp[i][j ...

  7. *关于TCP长连接,NAT超时,心跳包

    参考: http://www.jianshu.com/p/584707554ed7 1.TCP长连接 TCP连接建立后只要不明确关闭,逻辑上连接一直存在. TCP是有保活定时器的,可以打开保活定时器来 ...

  8. 【Visual Studio Code 】使用Visual Studio Code + Node.js搭建TypeScript开发环境

    1.准备工作 Node.js Node.js - Official Site Visual Studio Code Visual Studio Code - Official Site 安装Node. ...

  9. VS2010环境下.NET4.0中Tuple<T>的一个小BUG问题

    启动一个桌面程序后,发现一个窗体cfdata=null, 执行时发生错误, 但是在初始化的时候,我明明是cfdata=new Cfdata();为什么会出现这个错误呢. 我开始跟踪,发现当执行cfda ...

  10. JSP页面自动刷新

    1.页面自动刷新:把如下代码加入<head>区域中<meta http-equiv="refresh" content="20">,其中 ...