function [u,t_min] = LEM_get_UAS(UAS,pt,vertexes)
%

LOAD_TIME = 300;

num_UAS = length(UAS);
available = zeros(num_UAS,1);

for k = 1:num_UAS
    sched = UAS(k).schedule;
    [num_flights,dummy] = size(sched);
    if num_flights==1
        t_avail = sched(end,end) + LOAD_TIME;
    else
        t_avail = sched(end-1,end) + LOAD_TIME;
    end
    available(k) = t_avail;
end
[vals,indexes] = sort(available);
u = indexes(1);
t_min = vals(1);
return

u_list = find(vals==min(vals));
ind2 = indexes(u_list);
min_d = Inf;
min_index = 0;
num_ind2 = length(ind2);
for k = 1:num_ind2
    indk = ind2(k);
    v1 = vertexes(UAS(indk).schedule(1,1),:);
    if norm(v1-pt)<min_d
        min_d = norm(v1-pt);
        min_index = indk;
    end
end
u = min_index;
t_min = vals(1);
tch = 0;
