题目链接

排排序,找找做题的感觉...

对了,longlong用C++ 错了几次,我也是linux选手了....

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define MOD 1000000007
#define LL __int64
struct node
{
int u,c,num;
LL l;
}p[];
int flag[];
LL sum[];
int cmp(node a,node b)
{
if(a.u == b.u)
return a.c > b.c;
else
return a.u < b.u;
}
int cmp1(node a,node b)
{
return a.num < b.num;
}
int main()
{
int t,cas = ,n,m,q,i,st,maxz;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&n,&m,&q);
for(i = ;i < n;i ++)
flag[i] = ;
for(i = ;i < m;i ++)
scanf("%d%d%I64d",&p[i].u,&p[i].c,&p[i].l);
sort(p,p+m,cmp);
p[].num = ;
for(i = ;i < m;i ++)
{
if(p[i].u != p[i-].u)
p[i].num = ;
else
p[i].num = p[i-].num + ;
}
sort(p,p+m,cmp1);
sum[] = p[].l;
flag[p[].num] = ;
maxz = ;
for(i = ;i < m;i ++)
{
if(p[i].num != p[i-].num)
flag[p[i].num] = i;
sum[i] = sum[i-] + p[i].l;
maxz = max(maxz,p[i].num);
}
printf("Case #%d:\n",cas++);
for(i = ;i < q;i ++)
{
scanf("%d",&st);
if(st <= )
printf("0\n");
else if(st >= maxz)
printf("%I64d\n",sum[m-]);
else
printf("%I64d\n",sum[flag[st+]-]);
}
}
return ;
}

HDU 4020 Ads Proposal的更多相关文章

  1. hdu 2846 Repository

    http://acm.hdu.edu.cn/showproblem.php?pid=2846 Repository Time Limit: 2000/1000 MS (Java/Others)     ...

  2. hdu 5533 Dancing Stars on Me 水题

    Dancing Stars on Me Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...

  3. HDU 5536 Chip Factory 字典树

    Chip Factory Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...

  4. HDU 5538 L - House Building 水题

    L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...

  5. HDU 5514 Frogs 容斥定理

    Frogs Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5514 De ...

  6. HDU 5515 Game of Flying Circus 二分

    Game of Flying Circus Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...

  7. HDU 2846 Repository(字典树,每个子串建树,*s的使用)

    Repository Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  8. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  9. HDU:2846-Repository

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2846 Repository Time Limit: 2000/1000 MS (Java/Others) ...

随机推荐

  1. git 使用技巧

    让git不检测文件权限 在android根目录执行:repo forall -c git config core.filemode false即可 修改默认编辑器: git config –globa ...

  2. Delphi中的变量作用域简介

    1.在函数或过程中声明的变量是局部变量,只能在函数或过程中使用 2.在单元的implementation部分声明的变量是单元级的(又称模块级.窗体级)变量,该单元的所有函数与过程都能使用,其他引用该单 ...

  3. iscroll 4.0 滚动(水平和垂直)

    1.概述 iscroll 专注于页面滚动js.Iscroll滚动做的挺好,特别是针对手机网页(android.iphone)正好弥补手动滑屏的遗缺,而今研究一番,把代码贴出来,供大家参考. 2.isc ...

  4. 【JAVA与XML、dtd约束、Schema约束】

    一.XML. (1)XML:Extensible Markup Language (2)XML是一种标记语言. (3)XML的设计宗旨是传输数据,而不是显示数据. (4)XML标签没有被预定义,即使用 ...

  5. 如何减少JS的全局变量污染

    A,唯一变量 B,闭包

  6. Oracle【IT实验室】数据库备份与恢复之二:SQL*Loader

    2.1 基本知识 Oracle 的  SQL* LOADER  可以将外部格式化的文本数据加载到数据库表中.通常 与 SPOOL导出文本数据方法配合使用.     1.命令格式 SQLLDR keyw ...

  7. 命令模式/command模式/行为型模式

    举个栗子 指挥官向士兵下达命令,士兵执行 实现代码如下: class Soldier { public void exe() { System.out.println("执行命令" ...

  8. "Project facet Java version 1.7 is not supported"的问题解决的办法

    问题描述 在eclipse中,从SVN中检出project代码,拖拽式部署到local server中的时候,报出以下错误: 问题分析 问题产生的原因是,SVN中的代码是采用java 1.7开发编译的 ...

  9. 关于移动端1px边框问题

    <div class="z_nei_list"> <div class="z_name_left font-size3">身份证号:&l ...

  10. Jmeter之参数化(五)

    Jmeter用函数(__Random)批量添加的用法 首先点击  选项----->函数助手对话框-----> 这个是随机取值的意思 在这边输入取值的范围  然后点生成 即可 例如  从 数 ...