Computing integrated costs of sequences of operations with application to dictionaries