-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path13190.cpp
45 lines (39 loc) · 783 Bytes
/
13190.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
// iagorrr ;)
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
void solve(){
ll n, k;
cin >> n >> k;
vector<pair<string, ll>> drugs;
for(ll i = 0; i < n; ++i){
string s;
ll t;
cin >> s >>t;
drugs.emplace_back(s, t);
}
ll t = 1;
while(k){
for(auto [s, t_] : drugs){
if(t % t_ == 0 and t >= t_){
cout << t << ' ' << s << '\n';
k--;
if(k==0) return;
}
}
++t;
}
}
int main(){
fastio
ll T;
cin >> T;
while(T--){
solve();
}
return 0;
}
// AC.