Distributed Optimization Over Networked Systems: Time-Varying Costs And Privacy Preservation