fork download
  1. //shubham dextrous
  2.  
  3. #include<algorithm>
  4. #include<stdlib.h>
  5. #include<iostream>
  6. #include<stdio.h>
  7. using namespace std;
  8. struct name
  9. {
  10. long long id;
  11. long long attr;
  12. long long val;
  13. long long prio;
  14. }namee[100004];
  15. int cmp(struct name a,struct name b) //sorts the structure based on id first(level 1) then attr(level 2) and then priority(level 3)
  16. {
  17. if(a.id<b.id)
  18. return 1;
  19. else if(a.id>b.id)
  20. return 0;
  21. else
  22. {
  23. if(a.attr<b.attr)
  24. return 1;
  25. else if(a.attr>b.attr)
  26. return 0;
  27. else
  28. {
  29. if(a.prio<b.prio)
  30. return 1;
  31. else
  32. return 0;
  33. }
  34. }
  35. }
  36. long long l1,l2,l3,l4,arr1[100004],arr2[100004],arr3[100004],arr4[100004];
  37. int main()
  38. {
  39. long long t,n,count,f,i,w,e;
  40.  
  41. scanf("%lld %lld",&n,&f);
  42. for(i=0;i<n;i++)
  43. scanf("%lld %lld %lld %lld",&namee[i].id,&namee[i].attr,&namee[i].val,&namee[i].prio);
  44. stable_sort(namee,namee+n,cmp);
  45. for(i=0;i<n;i++)
  46. {
  47. arr1[i]=namee[i].id;
  48. arr2[i]=namee[i].attr;
  49. }
  50. while(f--)
  51. {
  52. scanf("%lld %lld",&w,&e);
  53. l1=lower_bound(arr1,arr1+n,w); //lower bound of w
  54. l2=upper_bound(arr1,arr1+n,w); //upper bound of w
  55. l4=upper_bound(arr2+l1,arr2+l2,e); //upper bound of e
  56. printf("%lld\n",namee[l4].val);
  57. }
  58. return 0;
  59. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
3 1
2 2 2
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:53:33: error: invalid conversion from ‘long long int*’ to ‘long long int’ [-fpermissive]
     l1=lower_bound(arr1,arr1+n,w); //lower bound of w 
                                 ^
prog.cpp:54:33: error: invalid conversion from ‘long long int*’ to ‘long long int’ [-fpermissive]
     l2=upper_bound(arr1,arr1+n,w); //upper bound of w
                                 ^
prog.cpp:55:37: error: invalid conversion from ‘long long int*’ to ‘long long int’ [-fpermissive]
     l4=upper_bound(arr2+l1,arr2+l2,e); //upper bound of e
                                     ^
prog.cpp:39:16: warning: unused variable ‘t’ [-Wunused-variable]
      long long t,n,count,f,i,w,e;
                ^
prog.cpp:39:20: warning: unused variable ‘count’ [-Wunused-variable]
      long long t,n,count,f,i,w,e;
                    ^
stdout
Standard output is empty