题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1271

题解:

这种题真是太神了!

只需要考虑被覆盖的次数的奇偶性,并且保证满足题意的点至多只有一个,所以考虑前缀和

该点以前前缀和都是偶数,该点及以后都是奇数! 然后就可以二分这个位置了。。。orz

给想出这道题的人跪了!

代码:

 #include<cstdio>

 #include<cstdlib>

 #include<cmath>

 #include<cstring>

 #include<algorithm>

 #include<iostream>

 #include<vector>

 #include<map>

 #include<set>

 #include<queue>

 #include<string>

 #define inf 2147483647

 #define maxn 250000

 #define maxm 500+100

 #define eps 1e-10

 #define ll long long

 #define pa pair<int,int>

 #define for0(i,n) for(int i=0;i<=(n);i++)

 #define for1(i,n) for(int i=1;i<=(n);i++)

 #define for2(i,x,y) for(int i=(x);i<=(y);i++)

 #define for3(i,x,y) for(int i=(x);i>=(y);i--)

 #define mod 1000000007

 using namespace std;

 inline int read()

 {

     int x=,f=;char ch=getchar();

     while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}

     while(ch>=''&&ch<=''){x=*x+ch-'';ch=getchar();}

     return x*f;

 }
int n,s[maxn],t[maxn],d[maxn];
int calc(int x)
{
int ret=;
for1(i,n)if(s[i]<=x)ret+=(min(x,t[i])-s[i])/d[i]+;
return ret;
} int main() { freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); int cs=read();
while(cs--)
{
n=read();
for1(i,n)s[i]=read(),t[i]=read(),d[i]=read();
ll l=,r=inf,mid;
while(l<=r)
{
mid=(l+r)>>;
if(calc(mid)&)r=mid-;else l=mid+;
//cout<<l<<' '<<r<<' '<<mid<<endl;
//cout<<( calc(mid)&1 )<<endl;
}
if(r==inf)printf("Poor QIN Teng:(\n");else printf("%lld %d\n",l,calc(l)-calc(l-));
} return ; }

最新文章

  1. C与指针(结构体指针,函数指针,数组指针,指针数组)定义与使用
  2. Action的搜索顺序(Struts2搜索Action的机制)
  3. asp.net解决高并发的方案.[转]
  4. loadrunner 的Administration Page页面设置
  5. 精品资源:40个实用的 PSD 贴纸模板《下篇》
  6. JS中对this的理解
  7. iOS - Library 库
  8. 理解模板引擎Razor 的原理(转载)
  9. Codeforces 263E
  10. (算法入门经典大赛 优先级队列)LA 3135(之前K说明)
  11. shell 字符串包含
  12. unity3d打开对话框
  13. Class类与Java反射
  14. mybatis快速入门(二)
  15. Data access between different DBMS and other txt/csv data source by DB Query Analyzer
  16. Tarjan求强连通分量 缩点
  17. 《算法》BEYOND 部分程序 part 1
  18. KVM虚拟化技术(四)安装虚拟机
  19. Composer 技巧(以 FastAdmin 项目为基础)(2018-12-25 更新)
  20. 由浅入深了解EventBus:(六)

热门文章

  1. input框中的背景文字
  2. 服务器端PHP多进程编程
  3. 9张思维导图学习Javascript(转)
  4. exists查询中子表可以是
  5. Spring各种传播特性源码实现的概览
  6. [上传下载] C#修改DownLoadHelper上传下载帮助类 (转载)
  7. Android-The specified child already has a parent. You must call removeView() on the child&#39;s parent first.
  8. OC基础-day06
  9. 开发错误日志之No matching bean of type [xxx] found for dependency
  10. Fedora 21 安装桌面环境