题目
> Sample Input 4 2 3759 6 3 123123 7 4 1000000 0 0
> Sample Output 79 32300
思路
类比单调栈,输入时将元素一个个插到数组末尾,由于位越高的数越大越好,每次进栈的时候做类似单调栈操作,就是一直保持数组降序单调性,同时每删去一个数耗一点d。
最后就有两种情况:
- 点数用完:后面直接进数组
- 都进了数组了却没用完点数:从后往前删(因为前面的都是挑过的够大的)
代码
#include <cstdio>
#include <cstdlib>
const int maxn = 100000 + 1000;
char num[maxn];
int n, d