-
Notifications
You must be signed in to change notification settings - Fork 0
/
grapes.cpp
46 lines (46 loc) · 1.11 KB
/
grapes.cpp
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
39
40
41
42
43
44
45
46
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
int main()
{
int t;
cin >> t;
for(int k = 1;k <= t;k++) {
int n,s;
cin >> n >> s;
int vis[100005] = {0};
multiset<int> v[100005];
multiset<int>::iterator it;
vector<int> ans;
for(int i = 0;i < n;i++) {
int a,b,c;
cin >> a;
b = a/s;
c = a%s;
v[b].insert(c);
if(vis[b] == 0) {
ans.push_back(b);
vis[b] = 1;
}
}
sort(ans.begin(),ans.end());
cout << "Scenario #" << k << ":\n\n";
for(int i = 0;i < ans.size();i++) {
int q = ans[i];
int j = 0;
cout << q << " | ";
for(it = v[q].begin();it != v[q].end();it++) {
// if(it != v[q].end()-1) {
// cout << (*it) << " ";
// }else {
cout << (*it) << " ";
// }
}
cout << endl;
}
cout << endl;
}
return 0;
}