Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include <stdio.h>
  2. long long ns[300001];
  3. long long ms;
  4.  
  5. int main(){
  6. int n,m;
  7. scanf("%d", &n);
  8. scanf("%d", &m);
  9. for(int i = 0; i < n; i++){
  10. scanf("%lld", &ns[i]);
  11. if(i > 0 && ns[i] > ns[i - 1])
  12. ns[i] = ns[i - 1];
  13. //printf("%lld\n", ns[i]);
  14. }
  15. int high = n;
  16. for(int i = 0; i < m; i++){
  17. scanf("%lld", &ms);
  18. int curr_high = high - 1;
  19. if(curr_high >= 0){
  20. while(curr_high >= 0 && ns[curr_high] < ms){
  21. curr_high--;
  22. }
  23. high = curr_high;
  24. }
  25. else{
  26. high = -1;
  27. }
  28. //printf("%d\n", high);
  29. }
  30. printf("%d\n", high + 1);
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement