http://codeforces.com/problemset/problem/747/C

题意:有n台机器,q个操作。每次操作从ti时间开始,需要ki台机器,花费di的时间。每次选择机器从小到大开始,如果可以完成任务,那么输出id总和,否则输出-1.

思路:简单的模拟,注意如果不能完成任务,那么ser数组是不能更新的。

 #include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
using namespace std;
#define INF 0x3f3f3f3f
#define N 100010
typedef long long LL;
int t[N], d[N], k[N];
LL ser[], tmp[]; int main() {
int n, q, k, t, d;
memset(ser, , sizeof(ser));
memset(tmp, , sizeof(tmp));
cin >> n >> q;
for(int i = ; i <= q; i++) {
scanf("%d%d%d", &t, &k, &d);
int cnt = , ans = ;
memcpy(tmp, ser, sizeof(tmp));
for(int j = ; j <= n && cnt < k; j++) {
if(tmp[j] <= t) {
cnt++; tmp[j] = t + d;
ans += j;
}
}
if(cnt < k) {
printf("-1\n");
} else {
memcpy(ser, tmp, sizeof(ser));
printf("%d\n", ans);
}
}
return ;
}

Codeforces 747C:Servers(模拟)的更多相关文章

  1. 【50.00%】【codeforces 747C】Servers

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. Codeforces 389B(十字模拟)

    Fox and Cross Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submi ...

  3. codeforces 591B Rebranding (模拟)

    Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...

  4. Codeforces 626B Cards(模拟+规律)

    B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input outp ...

  5. Codeforces 631C. Report 模拟

    C. Report time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...

  6. Codeforces 679B. Barnicle 模拟

    B. Barnicle time limit per test: 1 second memory limit per test :256 megabytes input: standard input ...

  7. CodeForces 382C【模拟】

    活生生打成了大模拟... #include <bits/stdc++.h> using namespace std; typedef long long LL; typedef unsig ...

  8. codeforces 719C (复杂模拟-四舍五入-贪心)

    题目链接:http://codeforces.com/problemset/problem/719/C 题目大意: 留坑...

  9. CodeForces 705C Thor (模拟+STL)

    题意:给定三个操作,1,是x应用产生一个通知,2,是把所有x的通知读完,3,是把前x个通知读完,问你每次操作后未读的通知. 析:这个题数据有点大,但可以用STL中的队列和set来模拟这个过程用q来标记 ...

随机推荐

  1. 经典的javascript函数实例,css的. #区别

    先贴javascript经典例子代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" &quo ...

  2. 引用log4j.jar包后,出现告警

    问题现象:在引用log4j包后,使用自己导出的jar包,编译测试例代码,在启动浏览器时出现以下告警:log4j:WARN No appenders could be found for logger ...

  3. HTTP Header

    1.User-Agent 记录访问当前网页的用户浏览器类型和版本,操作系统类型和版本.常见场景:根据不同浏览器和版本提供不同站点. JavaScript通过window.navigator.userA ...

  4. selenium webdriver自动化测试

    selenium家族介绍           Selenium IDE:Selenium IDE是嵌入到Firefox浏览器中的一个插件,实现简单的浏览器操作的录制与回放功能.   Selenium ...

  5. (TODO:)下载图片,报错:warning: could not load any Objective-C class information from the dyld shared cache. This will significantly reduce the quality of type information available.

    想使用NSInvocationOperation下载图片,然而并没有下载下来, NSData为nil, 还有报错:(打断点就报错) warning: could not load any Object ...

  6. JPA 2.1 Coverter 注解

    @Converter(autoApply = true) public class VehicleConverter implements AttributeConverter<Vehicle, ...

  7. RunLoop相关知识的总结

    RunLoop 即运行循环,也叫事件循环,本质为一个死循环.iOS一个程序运行起来之后,默认会开启一个运行循环,有需要处理的操作时,比如用户的输入事件时,RunLoop会自己跑起来运行,没有需要处理的 ...

  8. Linux从零单排(一):Google Chrome的安装

    刚刚安装了Linux ubuntu16.10系统,先装上我一直习惯用的Google Chrome 安装步骤如下: 1.终端输入 sudo wget https://repo.fdzh.org/chro ...

  9. Java中Set Map List 的区别

    java中set map list的区别: 都是集合接口 简要说明 set --其中的值不允许重复,无序的数据结构 list   --其中的值允许重复,因为其为有序的数据结构 map--成对的数据结构 ...

  10. 常用prototype函数

    $("spcode").value --取得当前页面的值的value,可以赋值 $F('spcode')         --不能赋值 $!spcode             - ...