CF1070C.Cloud Computing
普及+/提高
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Buber is a Berland technology company that specializes in waste of investor's money. Recently Buber decided to transfer its infrastructure to a cloud. The company decided to rent CPU cores in the cloud for n consecutive days, which are numbered from 1 to n. Buber requires k CPU cores each day.
The cloud provider offers m tariff plans, the i-th tariff plan is characterized by the following parameters:
- li and ri — the i-th tariff plan is available only on days from li to ri, inclusive,
- ci — the number of cores per day available for rent on the i-th tariff plan,
- pi — the price of renting one core per day on the i-th tariff plan.
Buber can arbitrarily share its computing core needs between the tariff plans. Every day Buber can rent an arbitrary number of cores (from 0 to ci) on each of the available plans. The number of rented cores on a tariff plan can vary arbitrarily from day to day.
Find the minimum amount of money that Buber will pay for its work for n days from 1 to n. If on a day the total number of cores for all available tariff plans is strictly less than k, then this day Buber will have to work on fewer cores (and it rents all the available cores), otherwise Buber rents exactly k cores this day.
Buber 是一家位于 Berland 的科技公司,专长于挥霍投资者的资金。最近,Buber 决定将其基础设施迁移至云平台。该公司计划在连续 n 天(编号从 1 到 n)内租用 CPU 核心。Buber 每天需要 k 个 CPU 核心。
云服务提供商提供了 m 种计费方案,其中第 i 种计费方案具有如下参数:
- li 和 ri —— 第 i 种计费方案仅在第 li 天至第 ri 天(含端点)期间可用;
- ci —— 在第 i 种计费方案下,每天最多可租用的 CPU 核心数;
- pi —— 在第 i 种计费方案下,租用一个 CPU 核心一天的价格。
Buber 可以在不同计费方案之间任意分配其所需的计算核心数。每天,Buber 可在每种当天可用的计费方案中租用任意数量的核心(从 0 到 ci)。同一种计费方案下每天租用的核心数可以任意变化。
求 Buber 在第 1 天至第 n 天这 n 天内所需支付的最少总金额。若某天所有可用计费方案所能提供的核心总数严格小于 k,则 Buber 当天只能使用更少的核心数(即租用所有可用的核心);否则,Buber 当天恰好租用 k 个核心。
输入格式
The first line of the input contains three integers n, k and m (1≤n,k≤106,1≤m≤2⋅105) — the number of days to analyze, the desired daily number of cores, the number of tariff plans.
The following m lines contain descriptions of tariff plans, one description per line. Each line contains four integers li, ri, ci, pi (1≤li≤ri≤n, 1≤ci,pi≤106), where li and ri are starting and finishing days of the i-th tariff plan, ci — number of cores, pi — price of a single core for daily rent on the i-th tariff plan.
输入的第一行包含三个整数 n、k 和 m(1≤n,k≤106,1≤m≤2⋅105),分别表示需要分析的天数、期望的每日核心数以及资费方案的数量。
接下来的 m 行每行描述一个资费方案。每行包含四个整数 li、ri、ci、pi(1≤li≤ri≤n,1≤ci,pi≤106),其中 li 和 ri 分别表示第 i 个资费方案的起始日与终止日,ci 表示核心数量,pi 表示在第 i 个资费方案下每日租用单个核心的价格。
输出格式
Print a single integer number — the minimal amount of money that Buber will pay.
输出一个整数——Buber 需要支付的最少金额。
输入输出样例
输入#1
5 7 3 1 4 5 3 1 3 5 2 2 5 10 1
输出#1
44
输入#2
7 13 5 2 3 10 7 3 5 10 10 1 2 10 6 4 5 10 9 3 4 10 8
输出#2
462
输入#3
4 100 3 3 3 2 5 1 1 3 2 2 4 4 4
输出#3
64
输入解题思路,AI测评打分。不知道怎么写?