Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long int
- map< string, int > mp;
- int main(){
- #ifdef ERFANUL007
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- int t;
- cin >> t;
- while(t--){
- getchar();
- string binder;
- getline(cin, binder);
- for(int i=0; i<(int)binder.size(); i++){
- cout << (char)toupper(binder[i]);
- }
- cout << '\n';
- int n, q, doller;
- cin >> n >> q >> doller;
- //cout << n << ' ' << q << ' ' << doller << '\n';
- mp.clear();
- for(int i=0; i<n; i++){
- string s;
- int x;
- cin >> s >> x;
- //cout << s << ' ' << x << '\n';
- mp[s] = x;
- }
- vector< pair< ll, string > > v;
- for(int i=0; i<q; i++){
- getchar();
- string name;
- getline(cin, name);
- //cout << name << '\n';
- int k; cin >> k;
- //cout << k << '\n';
- ll cost = 0;
- for(int j=0; j<k; j++){
- string s;
- int x;
- cin >> s >> x;
- //cout << s << ' ' << x << '\n';
- ll val = 1LL * x * mp[s];
- cost += val;
- }
- if(cost <= doller) v.push_back(make_pair(cost, name));
- }
- sort(v.begin(), v.end());
- if(v.size()){
- for(auto it : v){
- cout << it.second << '\n';
- }
- }
- else{
- cout << "Too expensive!\n";
- }
- cout << '\n';
- }
- #ifdef ERFANUL007
- fprintf(stderr, ">>> Runtime : %.9f\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement