Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- long long ns[300001];
- long long ms;
- int main(){
- int n,m;
- scanf("%d", &n);
- scanf("%d", &m);
- for(int i = 0; i < n; i++){
- scanf("%lld", &ns[i]);
- if(i > 0 && ns[i] > ns[i - 1])
- ns[i] = ns[i - 1];
- //printf("%lld\n", ns[i]);
- }
- int high = n;
- for(int i = 0; i < m; i++){
- scanf("%lld", &ms);
- int curr_high = high - 1;
- if(curr_high >= 0){
- while(curr_high >= 0 && ns[curr_high] < ms){
- curr_high--;
- }
- high = curr_high;
- }
- else{
- high = -1;
- }
- //printf("%d\n", high);
- }
- printf("%d\n", high + 1);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement