no, not the code efficiency. it affects the way of your system is handling the memory on your machine.
actually, when you are allocating memory for a variable in a function, the memory is taken from the current stack space. it’s a limited contiguous memory space, not shared between function calls, whose delimiters are pointed by ebp (base pointer) and esp (stack pointer) processor registers. the stack is used for a wide variety of tasks, like passing function parameters for example. but ! you have to be aware that this fast-accessible memory space is limited by the system itself, because of its properties. for instance, if there is no more space in the stack, your process can’t run anymore, because it cannot call functions. when a program tries to allocate too much memory on the stack, the system simply kills it (resulting in NZEC on codechef judge). to understand better the concept, you should look for internet pages talking about stack, recursive functions, terminal-recursive functions, calling conventions, etc.
when you are allocating memory globally, the memory is not taken from the stack anymore, but from the heap. thus, it is not restricted by the functions scopes, and can be accessed in the whole running process of your program (not outside, of course). the heap memory can be allocated freely until you have no more memory on your system. accessing it is not as fast as the stack, because the space is managed by a system called MMU (memory management unit) that maps the physical memory into addressable space. yeah, even if this memory space looks contiguous, the system is free to use the physical memory uncontiguously, by allocating random memory pages where they are available. it’s a really wider memory space than the stack. thus, it is a far better place for storing big structures (moreover if they can be shared between functions). i hope it’ll help you to understand.