用单调队列维护m个位置,找最小的
#include<cstdio>
#include<queue>
using namespace std;
int n,m;
priority_queue<int>q;
int main(){freopen("death.in","r",stdin);freopen("death.out","w",stdout);scanf("%d%d",&n,&m);for(int i=1;i<=n;i++) {int x;scanf("%d",&x);if(q.size()<m) q.push(-x);else{int tmp=q.top();q.pop();tmp-=x;q.push(tmp);}}printf("%d",-q.top());
}