2024.12.16 周一
Q1. 1000
Monocarp is playing yet another computer game. And yet again, his character is killing some monsters. There are $n$ monsters, numbered from $1$ to $n$, and the $i$-th of them has $a_i$ health points initially.
Monocarp's character has an ability that deals $k$ damage to the monster with the highest current health. If there are several of them, the one with the smaller index is chosen. If a monster's health becomes less than or equal to $0$ after Monocarp uses his ability, then it dies.
Monocarp uses his ability until all monsters die. Your task is to determine the order in which monsters will die.
------------------------独自思考分割线------------------------
-
昨天数据结构考试+第二题被位运算加构造卡了,就润了,所以就一道题..
A1.
- 在原有的基础上考虑加速加速操作。发现最终顺序和模 $k$ 之后大小有关。按照这种意义排序即可。
------------------------代码分割线------------------------
A1.
#include <bits/stdc++.h>
#define int long long //
#define endl '\n' // 交互/调试 关
using namespace std;
#define bug(BUG) cout << "bug:# " << (BUG) << endl
#define bug2(BUG1, BUG2) cout << "bug:# " << (BUG1) << " " << (BUG2) << endl
#define bug3(BUG1, BUG2, BUG3) cout << "bug:# " << (BUG1) << ' ' << (BUG2) << ' ' << (BUG3) << endl
void _();
signed main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cout << fixed << setprecision(6);
int T = 1;
cin >> T;
while (T--)
_();
return 0;
}
void _()
{
int n, k;
cin >> n >> k;
struct Node
{
/* data */
int x, i;
};
vector<Node> a(n);
for (int i = 0; i < n; i++)
{
int t;
cin >> t;
// a[i].x = k - t % k;
a[i].x = t % k;
a[i].x = !a[i].x ? k : a[i].x;
a[i].i = i;
// bug2(i + 1, a[i].x);
}
sort(a.begin(), a.end(), [](Node &a, Node &b)
{ return a.x - b.x ? a.x > b.x : a.i < b.i; });
for (auto [x, i] : a)
cout
<< i + 1 << ' ';
cout << endl;
}
标签:2024.12,------------------------,his,16,int,Monocarp,周一,monsters
From: https://www.cnblogs.com/jkkk/p/18612026