题解:

维护比这个大的第二大

代码:

#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;
int i,j,n,m,q,c;
struct node
{
int a,b;
}p[];
bool cmp(node a,node b)
{
if(a.a!=b.a) return a.a>b.a;
return a.b>b.b;
}
int sum[];
priority_queue<int, vector<int>, greater<int> > que;
int main()
{
while (~scanf("%d%d%d",&n,&m,&q))
{
while (!que.empty())que.pop();
for (i=;i<m;i++)scanf("%d%d",&p[i].a,&p[i].b);
sort(p,p+m,cmp);
sum[]=;
int a1,a2;
for (i=n,j=;i>=;i--)
{
for (;j<m;j++)
{
if (i<=p[j].a) que.push(p[j].b);
else break;
}
if ((int)que.size()<)
{
sum[i]=;
continue;
}
a1=que.top();
que.pop();
a2=que.top();
que.pop();
que.push(a1);
que.push(a2);
if(i-a2<) sum[i]=;
else sum[i]=i-a2;
}
while (q--)
{
scanf("%d",&c);
printf("%d\n",sum[c]);
}
}
return ;
}

最新文章

  1. U盘启动 WinPE系统维护工具 任意安装GHO/WIM/ESD系统映像 无广告专业版
  2. webpack 入门
  3. MarkDown初体验
  4. HTML 导航框架 (使用 Frame )
  5. 敏捷开发之道(四)Scrum概述
  6. Chp18: Hard
  7. winform 五子棋 判断输赢 分类: WinForm 2014-08-07 20:55 256人阅读 评论(0) 收藏
  8. curl批量伪造数据
  9. Windows Firewall Setting
  10. python笔记六(函数的参数、返回值)
  11. Mysql 设置远程连接
  12. git中Please enter a commit message to explain why this merge is necessary.
  13. 【 Gym - 101138F 】GukiZ Height (数学)
  14. mvc4使用KindEditor文本编辑器
  15. 2018.10.23 hdu2476String painter(区间dp)
  16. Angular2,Springboot,Zuul,Shiro跨域CORS请求踩坑实录
  17. confluence wiki 破解安装操作流程
  18. intellij IDEA与springboot项目建立
  19. makefile opencv的案例
  20. python-无参函数

热门文章

  1. div转svg svg转canvas svg生成图片及图片下载 分享
  2. 风景区的面积及道路状况分析问题 test
  3. [SpringBoot] - 上线一份项目记录
  4. 用python + hadoop streaming 编写分布式程序(三) -- 自定义功能
  5. UVa 1220 Hali-Bula的晚会(树的最大独立集)
  6. 一个对iBatis的总结写的不错(转载)
  7. Windows 2003 server下载
  8. sqlserver 存入DB中的中文乱码
  9. STL_算法_02_排序算法
  10. Beta冲刺二——《WAP团队》