Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare npotions. Anton has a special kettle, that can prepare one potions in x seconds. Also, he knows spells of two typ…
题目链接:http://codeforces.com/problemset/problem/734/C 题目大意:要制作n个药,初始制作一个药的时间为x,魔力值为s,有两类咒语,第一类周瑜有m种,每种咒语使制作一个药的时间变成a[i],花费b[i]的魔力,第二类咒语有k种,每种咒语瞬间产生c[i]个药,花费d[i]的魔力,c[i]和d[i]都是不递减的,求最短时间内产生n个药的时间.解题思路:因为c[i]和d[i]都是不降的,所以可以枚举a[i],然后二分查找花费小于t-b[i]的第二类咒语.注…
题目链接:http://codeforces.com/contest/734/problem/C C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interesting computer game, but now he i…
C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next…
题意: 有一个谷仓容量为\(n\),谷仓第一天是满的,然后每天都发生这两件事: 往谷仓中放\(m\)个谷子,多出来的忽略掉 第\(i\)天来\(i\)只麻雀,吃掉\(i\)个谷子 求多少天后谷仓会空 分析: 分类讨论: 1. \(n \leq m\) 每天都会把谷仓放满,所以第\(n\)后会变空 2. \(n > m\) 前\(m\)天后谷仓还一直都是满的 第\(m+1\)天后还剩\(n-m-1\),第\(m+2\)天后还剩\(n-m-1-2\) 第\(m+i\)天后还剩\(n-m-\frac{…
C. Anton and Making Potions 题目连接: http://codeforces.com/contest/734/problem/C Description Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potions. Anton has a…
codeforces734C——Anton and Making Potions详解 Anton and Making Potions 题目描述(google翻译) 安东正在玩一个非常有趣的电脑游戏,但现在他被困在其中一个级别.为了进入下一个级别,他必须准备n个药水. 安东有一个特殊的水壶,可以在x秒内准备一个魔药.此外,他知道两种类型的法术可以加快准备魔药的过程. 这种类型的法术加速了一种魔药的准备时间.有这种类型的m个法术,其中第i个成本为bi manooints并且将每个药水的准备时间改为…
Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next le…
CodeForce-734C Anton and Making Potions  C. Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interesting computer game, but now he is stuck…
Anton and Making Potions time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next le…
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard output Anton is playing a very interesting computer game, but now he is stuck at one of the levels. To pass to the next level he has to prepare n potio…
C. Anton and Fairy Tale 题目连接: http://codeforces.com/contest/785/problem/C Description Anton likes to listen to fairy tales, especially when Danik, Anton's best friend, tells them. Right now Danik tells Anton a fairy tale: "Once upon a time, there liv…
http://codeforces.com/contest/734/problem/C 因为有两种操作,那么可以这样考虑, 1.都不执行,就是开始的答案是n * x 2.先执行第一个操作,然后就会得到一个time和left.就是你会得到一个新的用时,和一个剩下的魔法数,然后在第二个操作数中二分,二分第一个小于等于left的值,意思就是我现在还拥有left点魔法,能够买最多多少个技能的意思. 就是,看着样例一 得到的会是 time : 40s    80s 60s left   : 79 89 5…
E. Anton and Tree time limit per test: 3 seconds memory limit per test :256 megabytes input:standard input output: standard output Anton is growing a tree in his garden. In case you forgot, the tree is a connected acyclic undirected graph. There are …
题目链接:http://codeforces.com/contest/734/problem/C 题意: 玩一个游戏,一开始升一级需要t秒时间,现在有a, b两种魔法,两种魔法分别有m1, m2种效果: 对应使用a1[i]魔法需要a2[i]金币,使用b1[i]魔法需要b2[i]金币: 每种魔法最多只能使用一次,问升到n(n<=1e+5)级最少需要多少时间: 注意:给出的b1, b2数组是升序排列的: 思路:对每一个a魔法找到最大的b1魔法jj, 即为使用此a魔法需要最少时间的情况:再找到所有jj…
题目链接:http://codeforces.com/contest/732/problem/D 题意: 在m天中要考k个课程, 数组a中有m个元素,表示第a[i]表示第i天可以进行哪门考试,若a[i]为0,则表示当天不能参加任何科目的考试,只能预习或者休息: 数组b中有k个元素,b[i]表示科目i需要复习几天才能通过: 问最快需要几天能通过所有考试,如果不能完成所有科目考试,输出-1: 思路: 用二分方法直接找满足条件的最小的数,其中数是指当前天是第几天,条件是指当前天以前是否能考完所有科目(…
LINK time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output The teacher gave Anton a large geometry homework, but he didn't do it (as usual) as he participated in a regular round on Codeforces. In…
Intervals 题目连接: http://codeforces.com/gym/100231/attachments Description 给你n个区间,告诉你每个区间内都有ci个数 然后你需要找一个最小的点集,使得满足这n个区间的条件 Input n 然后li,ri,ci Output 输出最小点集大小 Sample Input 5 3 7 3 8 10 3 6 8 1 1 3 1 10 11 1 Sample Output 6 Hint 题意 题解: 线段树+二分+贪心 首先我们贪心一…
题目链接: http://codeforces.com/problemset/problem/484/B 题意: 求a[i]%a[j] (a[i]>a[j])的余数的最大值 分析: 要求余数的最大值非常明显a[i]越接近a[j]的倍数则余数越大 ,因此我们将全部的元素从大到小排序 : 然后枚举a[j]的倍数 ,二分查找小于a[i]倍数的最大值,然后更新余数的最大值. 代码例如以下: #include <iostream> #include <cstdio> #include…
D. Array Division time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecuti…
题目链接:https://codeforces.com/problemset/problem/570/D 题解: 这种题,基本上容易想到DFS序. 然后,我们如果再把所有节点分层存下来,那么显然可以根据 $in[v],out[v]$ 在层内二分出一段属于 $v$ 的子树的节点. 那么我们进一步考虑,如果把一层的节点,按 $a \sim z$ 再分开来,用一个 $S[c][d]$ 数组来存所有字母为 $c$,深度为 $d$ 的节点的 $in[]$ 值. 这样一来,对于一个询问 $v,h$,就在 $…
题目链接:http://codeforces.com/problemset/problem/785/E 其实可以CDQ分治... 我们只要用一个数据结构支持单点修改,区间查询比一个数大(小)的数字有多少个就可以了. 考虑分块,每段区间之内有排序或者二分查询比一个数大的树的个数的操作. 复杂度${O(qn \sqrt n log_{2}^{\sqrt n})}$ #include<iostream> #include<cstdio> #include<algorithm>…
http://codeforces.com/problemset/problem/847/B 题意:给你n个数(n<2e5)把它们分成若干组升序的子序列,一行输出一组.分的方法相当于不断找最长递增子序列,将它们删除,然后继续找,直到删光整个初始数列. 题解:第一直觉是开一个vector<int> n[maxn].每读取一个数x,if(x>v[i].back())v[i].push_back(x);else v[++cnt].push_back(x).交了一发TLE了.然后分析一下,…
C. Mike and Chocolate Thieves time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! As…
C. Hard Process 题目连接: http://www.codeforces.com/contest/660/problem/C Description You are given an array a with n elements. Each element of a is either 0 or 1. Let's denote the length of the longest subsegment of consecutive elements in a, consisting…
链接: http://codeforces.com/problemset/problem/955/C 题意: Q次询问(1≤Q≤1e5),每次询问给出两个整数L, R(1≤L≤R≤1e18),求所有符合条件的整数x的个数.条件为:L≤x≤R,x = a的p次方(a, p为整数且a>0, p>1). 分析: 一.当指数p=3时,底数a最多有1e6个,由于指数增加时底数收敛得很快,所以我们可以将p>=3时的所有x放进vector里排序去重(预处理),求x的个数的时候二分查找即可.二.对于p=…
题目链接:http://codeforces.com/contest/837/problem/F 题意:如题QAQ 解法:参考题解博客:http://www.cnblogs.com/FxxL/p/7282909.html    由于新生成的m+1个数列第一个肯定为0,所以可以忽略掉,当作每次新生成的数列只拥有m个元素    来枚举一个例子,可以发现规律. 当a[] = {1,0,0,0,0}时,手动推出的矩阵如下: 可以发现对于这个矩阵显然是满足杨辉三角的,我们二分出一个值后可以直接利用组合数来…
题目链接: http://codeforces.com/contest/651/problem/D D. Image Preview time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasya's telephone contains n photos. Photo number 1 is currently opened on…
http://codeforces.com/problemset/problem/778/A 题意:给出字符串s和字符串p,还有n个位置,每一个位置代表删除s串中的第i个字符,问最多可以删除多少个字符使得s串依旧包含p串. 思路:想到二分,以为二分做法依旧很暴力.但是别人的做法确实就是二分暴力搞啊. 枚举删除字符数,然后判断的时候如果s串包含p串,那么可以往右区间找,否则左区间找. #include <bits/stdc++.h> using namespace std; #define N…
题目链接 http://codeforces.com/problemset/problem/729/C 题意:n个价格c[i],油量v[i]的汽车,求最便宜的一辆使得能在t时间内到达s,路途中有k个位置在g[i]的加油站,可以免费加满油,且不耗时间.每辆车有两种运行模式可以随时切换:1.每米一分钟两升油:2.每米两分钟一升油. 看到10^5次加上循环两次就想到二分或者线段树或者看错题意了. 这题二分查找一下汽油就可以了,找到最少多少汽油够到达,然后再for一遍找汽油量大的且价格便宜的车即可. 还…