二分比较容易想到

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<cassert>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define C 0.5772156649
#define pi acos(-1.0)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#pragma comment(linker, "/STACK:1024000000,1024000000") using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; ll a,b;
bool ok(ll l,ll r,ll t,ll m)
{
if(a+(r-)*b<=t)
{
ll p=a*(r-l+)+(l+r-)*(r-l+)/*b; return p<=t*m;
}
return ;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll n;
cin>>a>>b>>n;
while(n--)
{
ll l,t,m;
cin>>l>>t>>m;
ll L=l,R=*N;
while(L<R-)
{
ll mid=(L+R)/;
// cout<<L<<" "<<mid<<" "<<R<<endl;
if(ok(l,mid,t,m))L=mid;
else R=mid;
}
if(a+(L-)*b<=t)cout<<L<<endl;
else cout<<-<<endl;
}
return ;
}
/********************
2 3 1
148990 913922 18257
********************/

,而结论就是对于一个递增的数列,每次把m个数减小1,一共减小t次,当最大的那个数小于t,而且数列总和小于t*m时,那么可以取完,否则就不行

Tavas and Karafs 二分+结论的更多相关文章

  1. C. Tavas and Karafs 二分查找+贪心

    C. Tavas and Karafs #include <iostream> #include <cstdio> #include <cstring> #incl ...

  2. CF Tavas and Karafs (二分)

    Tavas and Karafs time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  3. CodeForces 535C Tavas and Karafs —— 二分

    题意:给出一个无限长度的等差数列(递增),每次可以让从l开始的m个减少1,如果某个位置已经是0了,那么可以顺延到下一位减少1,这样的操作最多t次,问t次操作以后从l开始的最长0序列的最大右边界r是多少 ...

  4. Codeforces 535C - Tavas and Karafs

    535C - Tavas and Karafs 思路:对于满足条件的r,max(hl ,hl+1 ,hl+2 ,......,hr )<=t(也就是hr<=t)且∑hi<=t*m.所 ...

  5. CF 535c Tavas and Karafs

    Tavas and Karafs Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u S ...

  6. Codeforces Round #299 (Div. 1) A. Tavas and Karafs 水题

    Tavas and Karafs Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/536/prob ...

  7. 二分搜索 Codeforces Round #299 (Div. 2) C. Tavas and Karafs

    题目传送门 /* 题意:给定一个数列,求最大的r使得[l,r]的数字能在t次全变为0,每一次可以在m的长度内减1 二分搜索:搜索r,求出sum <= t * m的最大的r 详细解释:http:/ ...

  8. 【Codeforces Round #299 (Div. 2) C】 Tavas and Karafs

    [链接] 我是链接,点我呀:) [题意] 给你一个规则,让你知道第i根萝卜的高度为si = A+(i-1)*B 现在给你n个询问; 每次询问给你一个固定的起点l; 让你找一个最大的右端点r; 使得l. ...

  9. 4.9 省选模拟赛 划分序列 二分 结论 树状数组优化dp

    显然发现可以二分. 对于n<=100暴力dp f[i][j]表示前i个数分成j段对于当前的答案是否可行. 可以发现这个dp是可以被优化的 sum[i]-sum[j]<=mid sum[i] ...

随机推荐

  1. windows7下搭建django开发环境

    Django 是 Python 编程语言驱动的一个开源模型-视图-控制器(MVC)风格的 Web 应用程序框架. 使用 Django,我们在几分钟之内就可以创建高品质.易维护.数据库驱动的应用程序. ...

  2. 洛谷 P2073 送花

    这题其实可以用vector水掉! 定义: 记住要用结构体(c为价格,x为美丽值)! 以c排序. struct Node { int x,c; bool operator < (const &am ...

  3. Linux bridge 资料链接

    1.Performance Evalution of Linux Bridge https://tnt.aufbix.org/_media/linux/yu-linux-tsm2004.pdf 2.L ...

  4. Oracle11g的安装卸载及经常使用工具的使用

    Oracle11g的安装卸载及经常使用工具的使用 目的: (1) 掌握Oracle 11g数据库的安装与卸载过程. Oracle11g的安装卸载及经常使用工具的使用 目的: (1) 掌握Oracle  ...

  5. Java集合类学习记录

    被标记为transient的属性在对象被序列化的时候不会被保存int[] arr1 = {1, 2, 3, 4, 5}; int[] arr2 = Arrays.copyOf(arr1, new_le ...

  6. LeetCode: Max Consecutive Ones

    这题最关键的是处理最开始连续1和最后连续1的方式,想到list一般在最前面加个node的处理方式,在最前面和最后面加0即可以很好地处理了 public class Solution { public ...

  7. 完美修改iOS项目名

    注意:重命名项目时,记得先备份好一份 1.选中旧项目名,改为新项目名: 选择rename: 2.修改相关文件夹名称: 3.全局搜索旧项目名称,然后替换为新项目名称: 4.经过步骤3的替换,再次全局搜索 ...

  8. MySQL-5.7 DELETE语句详解

    1.语法 (1)单表 DELETE [LOW_PRIORITY] [QUICK] [IGNORE] FROM tbl_name [PARTITION (partition_name [, partit ...

  9. CreateWindow创建无边框 可拉伸窗体

    createwindow 定义 HWND WINAPI CreateWindow( _In_opt_ LPCTSTR lpClassName, _In_opt_ LPCTSTR lpWindowNam ...

  10. const修饰的常量 不能被直接修改 但是可以通过指针进行间接修改

    大家都知道如下代码中,被const限定的a是不可以被直接修改的 void main() { const int a = 3; a=1; } 在C++中const修饰的常量,不能被直接修改,但是可以通过 ...