CF GYM 100703B Energy Saving
题意:王子每月买m个灯泡给n个房间换灯泡,如果当前有的灯泡数够列表的第一个房间换的就全换,直到灯泡不够为止,给出q个查询,查询x月已经换好几个房子,手里还剩多少灯泡。
解法:水题……小模拟。
代码:
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<time.h>
#include<stdlib.h>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#define LL long long
using namespace std;
int a[1005], ans[100005][2];
int main()
{
int n, m;
while(~scanf("%d%d", &n, &m))
{
int cnt = 0;
for(int i = 0; i < n; i++)
{
scanf("%d", &a[i]);
}
ans[0][0] = 0, ans[0][1] = 0;
int j = 0;
for(int i = 1; i <= 100000; i++)
{
cnt++;
ans[i][0] = ans[i - 1][0];
ans[i][1] = ans[i - 1][1] + m;
while(j < n && a[j] <= ans[i][1])
{
ans[i][0]++;
ans[i][1] -= a[j];
j++;
}
if(j == n)
break;
}
int q;
scanf("%d", &q);
while(q--)
{
int x;
scanf("%d", &x);
if(x > cnt)
x = cnt;
printf("%d %d\n", ans[x][0], ans[x][1]);
}
}
return 0;
}
CF GYM 100703B Energy Saving的更多相关文章
- Codeforces Gym 100269E Energy Tycoon 贪心
题目链接:http://codeforces.com/gym/100269/attachments 题意: 有长度为n个格子,你有两种操作,1是放一个长度为1的东西上去,2是放一个长度为2的东西上去 ...
- CF Gym 102028G Shortest Paths on Random Forests
CF Gym 102028G Shortest Paths on Random Forests 抄题解×1 蒯板子真jir舒服. 构造生成函数,\(F(n)\)表示\(n\)个点的森林数量(本题都用E ...
- CF gym 101933 K King's Colors —— 二项式反演
题目:http://codeforces.com/gym/101933/problem/K 其实每个点的颜色只要和父亲不一样即可: 所以至多 i 种颜色就是 \( i * (i-1)^{n-1} \) ...
- cf Gym 101086M ACPC Headquarters : AASTMT (Stairway to Heaven)
题目: Description standard input/output As most of you know, the Arab Academy for Science and Technolo ...
- CF Gym 100685A Ariel
传送门 A. Ariel time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- CF Gym 100685E Epic Fail of a Genie
传送门 E. Epic Fail of a Genie time limit per test 0.5 seconds memory limit per test 64 megabytes input ...
- CF GYM 100703A Tea-drinking
题意:龙要制作n个茶,每个茶的配方是一个字符串,两个字符串之间有一个差值,这个差值为两个字符串每个对应字母之间差的绝对值的最大值,求制作所有茶时获得的所有差值中的最大值. 解法:克鲁斯卡尔.将茶的配方 ...
- CF GYM 100703F Game of words
题意:两个人玩n个游戏,给出每人玩每个游戏的时间,两个人需要在n个游戏中挑m个轮流玩,求最短时间. 解法:dp.(这场dp真多啊……话说也可以用最小费用最大流做……然而并不会XD)dp[i][j][k ...
- CF GYM 100703G Game of numbers
题意:给n个数,一开始基数为0,用这n个数依次对基数做加法或减法,使基数不超过k且不小于0,输出最远能运算到的数字个数,输出策略. 解法:dp.dp[i][j]表示做完第i个数字的运算后结果为j的可能 ...
随机推荐
- PHP webserver 之 soap 生成wsdl文件
<?php /** * Copyright (c) , Braulio Jos?Solano Rojas * All rights reserved. * * Redistribution an ...
- easyui 文本框 显示提示信息data-options="prompt:'格式:水箱支架-京东汽配店铺-图集(大图/图集6)'"
<tr> <td>图集6:</td> <td> <input class="easyui-textbox" data-opti ...
- .net google calendar
https://developers.google.com/gdata/client-cs http://www.codeproject.com/Articles/64474/How-to-Read- ...
- Mapped Statements collection does not contain value for ResearcherMapper.方法名
搞了半天, 原来是映射文件没加, 新手常遇到的问题. Mapped Statements collection does not contain value for后面是什么类什么方法之类的: 错误原 ...
- 监控SQL Server的job执行情况
在服务器没有设置发邮件并且不允许发邮件的情况下, 可以通过下列语句来检查SQL Server 的job的执行情况 select top 150 a.run_date,a.run_time, b.nam ...
- Oracle和Redhat下载地址
Oracle RedHat 用户名:zhangwei900808@126.com 密码:@XxxxxXxxxxxx 有网友想要的,请在留言板给我留言,我会把用户名和密码发给你!
- 1040: [ZJOI2008]骑士 - BZOJ
Description Z国的骑士团是一个很有势力的组织,帮会中汇聚了来自各地的精英.他们劫富济贫,惩恶扬善,受到社会各界的赞扬.最近发生了一件可怕的事情,邪恶的Y国发动了一场针对Z国的侵略战争.战火 ...
- PAT-乙级-1007. 素数对猜想 (20)
1007. 素数对猜想 (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 让我们定义 dn 为:dn = ...
- Delphi逆向
Delphi反汇编内部字符串处理函数/过程不完全列表 名称 参数 返回值 作用 等价形式 / 备注 _PStrCat EAX :目标字符串 EDX :源字符串 EAX 连接两个 Pascal 字符串 ...
- VS2005中SetUnhandledExceptionFilter函数应用
很多软件通过设置自己的异常捕获函数,捕获未处理的异常,生成报告或者日志(例如生成mini-dump文件),达到Release版本下追踪Bug的目的.但是,到了VS2005(即VC8),Microsof ...