ds
2024-07-29 11:07:21
发布于:浙江
0阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
int a[1000000];
int k;
struct node{
int val,id;
friend bool operator <(const node &a,const node&b){
if(a.val != b.val){
return a.val<b.val;
}
else{
return a.id>b.id;
}
}
};
int main(){
freopen("monster.in","r",stdin);
freopen("monster.out","w",stdout);
int n,k;
cin >>n>>k;
priority_queue<node>g;
for(int i = 1;i<=n;i++){
int val;
cin >>val;
g.push({val,i});
}
while(!g.empty()){
node fr = g.top();
g.pop();
fr.val -= k;
if(fr.val <=0){
cout <<fr.id<<" ";
continue;
}
g.push(fr);
}
fclose(stdin);
fclose(stdout);
return 0;
}
这里空空如也
有帮助,赞一个