-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1849B.cpp
More file actions
38 lines (29 loc) · 791 Bytes
/
1849B.cpp
File metadata and controls
38 lines (29 loc) · 791 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
long long n, k;
cin >> n >> k;
vector<pair<long long, long long>> monsters(n);
for (long long i = 0; i < n; i++) {
long long x;
cin >> x;
long long r = x % k;
if (r == 0) r = k;
monsters[i] = {r, i + 1};
}
sort(monsters.begin(), monsters.end(), [&](auto &a, auto &b) {
if (a.first != b.first)
return a.first > b.first;
return a.second < b.second;
});
for (auto &m : monsters)
cout << m.second << " ";
cout << "\n";
}
return 0;
}