fork download
  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<string>
  5. #include<map>
  6. #include<vector>
  7. using namespace std;
  8. struct store
  9. {
  10. string name;
  11. long long start_price,last_price;
  12. store(string name,long long start_price,long long last_price)
  13. {
  14. this->name=name;
  15. this->start_price=start_price;
  16. this->last_price=last_price;
  17. }
  18. };
  19.  
  20.  
  21. int main()
  22. {
  23. map<string,long long>ma;
  24. vector<store>v;
  25. string x,y;
  26. long long cost,cost1,count;
  27. long long i,t,m,j,p,k;
  28. scanf("%lld",&t);
  29. for(i=1;i<=t;i++)
  30. {
  31. scanf("%lld",&m);
  32. for(j=1;j<=m;j++)
  33. {
  34.  
  35. cin>>x>>cost>>cost1;
  36. v.push_back(store(x,cost,cost1));
  37. }
  38. scanf("%lld",&p);
  39. for(j=1;j<=p;j++)
  40. {
  41. cin>>cost;
  42. count=0;
  43. for(k=0;k<v.size();k++)
  44. {
  45.  
  46. if(cost>=v[k].start_price&&cost<=v[k].last_price)
  47. {
  48. count=count+1;
  49. y=v[k].name;
  50. }
  51. }
  52. if(count==1)
  53. {
  54.  
  55. cout<<y<<"\n";
  56.  
  57.  
  58. }
  59. else
  60. {
  61. cout<<"UNDETERMINED\n";
  62. }
  63. }
  64. v.clear();
  65. }
  66.  
  67. }
Time limit exceeded #stdin #stdout 5s 3300KB
stdin
Standard input is empty
stdout
Standard output is empty