A9134 | Oh Sweet Beaverette
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
— Oh my sweet Beaverette, would you fancy a walk along a wonderful woodland belt with me?
— Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcoming walk. He needed to cut down several trees.
Let's consider the woodland belt as a sequence of trees. Each tree $i$ is described by the esthetic appeal $a_{i}$ — some trees are very esthetically pleasing, others are 'so-so', and some trees are positively ugly!
The Smart Beaver calculated that he needed the following effects to win the Beaverette's heart:
- The first objective is to please the Beaverette: the sum of esthetic appeal of the remaining trees must be maximum possible;
- the second objective is to surprise the Beaverette: the esthetic appeal of the first and the last trees in the resulting belt must be the same;
- and of course, the walk should be successful: there must be at least two trees in the woodland belt left.
Now help the Smart Beaver! Which trees does he need to cut down to win the Beaverette's heart?
— Of course, my Smart Beaver! Let us enjoy the splendid view together. How about Friday night?
At this point the Smart Beaver got rushing. Everything should be perfect by Friday, so he needed to prepare the belt to the upcoming walk. He needed to cut down several trees.
Let's consider the woodland belt as a sequence of trees. Each tree $i$ is described by the esthetic appeal $a_{i}$ — some trees are very esthetically pleasing, others are 'so-so', and some trees are positively ugly!
The Smart Beaver calculated that he needed the following effects to win the Beaverette's heart:
- The first objective is to please the Beaverette: the sum of esthetic appeal of the remaining trees must be maximum possible;
- the second objective is to surprise the Beaverette: the esthetic appeal of the first and the last trees in the resulting belt must be the same;
- and of course, the walk should be successful: there must be at least two trees in the woodland belt left.
Now help the Smart Beaver! Which trees does he need to cut down to win the Beaverette's heart?
输入格式
The first line contains a single integer $n$ — the initial number of trees in the woodland belt, $2<=n$ . The second line contains space-separated integers $a_{i}$ — the esthetic appeals of each tree. All esthetic appeals do not exceed $10^{9}$ in their absolute value.
- to get 30 points, you need to solve the problem with constraints: $n<=100$ (subproblem A1);
- to get 100 points, you need to solve the problem with constraints: $n<=3·10^{5}$ (subproblems A1+A2).
- to get 30 points, you need to solve the problem with constraints: $n<=100$ (subproblem A1);
- to get 100 points, you need to solve the problem with constraints: $n<=3·10^{5}$ (subproblems A1+A2).
输出格式
In the first line print two integers — the total esthetic appeal of the woodland belt after the Smart Beaver's intervention and the number of the cut down trees $k$ .
In the next line print $k$ integers — the numbers of the trees the Beaver needs to cut down. Assume that the trees are numbered from 1 to $n$ from left to right.
If there are multiple solutions, print any of them. It is guaranteed that at least two trees have equal esthetic appeal.
In the next line print $k$ integers — the numbers of the trees the Beaver needs to cut down. Assume that the trees are numbered from 1 to $n$ from left to right.
If there are multiple solutions, print any of them. It is guaranteed that at least two trees have equal esthetic appeal.
输入输出样例
输入 #1
5 1 2 3 1 2
输出 #1
8 1 1
输入 #2
5 1 -2 3 1 -2
输出 #2
5 2 2 5
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted