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. 2016 年 50 个最佳的轻量级 JavaScript 框架和库

    作者:IT程序狮链接:https://zhuanlan.zhihu.com/p/24598210来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 回顾今年已发布的 JS ...

  2. Thymeleaf 与 Javascript

    在 javascript 代码中使用 Thymeleaf 模板引擎: <script th:inline="javascript"> $("#content& ...

  3. oracle+servlet+extjs4 分页表格布局示例代码

    Log.java package com.example.entity; import java.util.Date; public class Log { private int id; priva ...

  4. JMeter学习-033-JMeter BeanShell 脚本应用实例之参数变量修改

    BeanShell脚本是JMeter自动化测试过程中不可或缺的提升技能之一,BeanShell脚本编写类似于Java脚本.它可以获取.修改系统定义或用户定义的变量值,同时也可以进行一些相应的测试数据处 ...

  5. matlab直方图均衡,使用向量优化

    matlab自带有histeq函数对图像进行直方图均衡 自己写了一个,改成向量化形式,效率提高了一点,但是比自带的还是差很多,差不多9倍 function D = my_histeq(I) [m,n] ...

  6. Python开发【十一章】:RabbitMQ队列

    RabbitMQ队列 rabbitMQ是消息队列:想想之前的我们学过队列queue:threading queue(线程queue,多个线程之间进行数据交互).进程queue(父进程与子进程进行交互或 ...

  7. 移动Web开发调研

    背景 在移动互联网浪潮下,移动设备普及,对配置需要考虑移动端设备可访问性.Web作为最贴近用户的配置手段,面向从PC端传统页面,向移动端页面的转型. 概念 PC Web: 面向传统PC电脑的浏览器开发 ...

  8. cygwin E437

    这个简单错误居然查到了 报错E437: terminal capability "cm" required 执行:# export TERM=xterm

  9. Hadoop中Combiner的使用

    注:转载自http://blog.csdn.net/ipolaris/article/details/8723782 在MapReduce中,当map生成的数据过大时,带宽就成了瓶颈,怎样精简压缩传给 ...

  10. Java中对象创建过程

    本文介绍的对象创建过程仅限于普通Java对象,不包括数组和Class对象. 1.类加载检查 虚拟机遇到一条new指令时,首先去检查该指令的参数能否在常量池中定位到一个类的符号引用,并且检查这个符号引用 ...