Maximum weight independent sets and matchings in sparse random graphs. Exact results using the local weak convergence method