Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int n;
- scanf("%d",&n);
- int A[101];
- for(int i=0;i<n;++i){
- scanf("%d",&A[i]);
- }
- int m;
- scanf("%d",&m);
- int B[101];
- for(int i=0;i<m;++i){
- scanf("%d",&B[i]);
- }
- int C[101];
- int min=100000;
- for(int i=0;i<n;++i){
- C[i] = 100000;
- }
- int ci = 0;
- int sz = 0;
- while(n > 0) {
- for(int i = 0; i < n / 2; i ++) {
- if(min > A[i]) {
- min = A[i];
- }
- }
- if(C[ci] > min){
- C[ci] = min;
- ci++;
- }
- //printf("%d ", min);
- min = 100000;
- n /= 2;
- }
- sz = ci;
- min=100000;
- ci=0;
- while(m>0){
- for(int i=0;i<m/2;++i){
- if(min>B[i]){
- min=B[i];
- }
- }
- if(C[ci]>min){
- C[ci]=min;
- }
- ci++;
- //printf("%d",min);
- min=100000;
- m/=2;
- }
- for(int i = 0; i < sz; i++) {
- if(C[i] == 100000) {
- break;
- }
- printf("%d ", C[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement