HDU 4020 Ads Proposal
排排序,找找做题的感觉...
对了,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的更多相关文章
- hdu 2846 Repository
http://acm.hdu.edu.cn/showproblem.php?pid=2846 Repository Time Limit: 2000/1000 MS (Java/Others) ...
- 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 ...
- HDU 5536 Chip Factory 字典树
Chip Factory Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid= ...
- HDU 5538 L - House Building 水题
L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- HDU 5514 Frogs 容斥定理
Frogs Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5514 De ...
- HDU 5515 Game of Flying Circus 二分
Game of Flying Circus Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...
- HDU 2846 Repository(字典树,每个子串建树,*s的使用)
Repository Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total ...
- HDU 5643 King's Game 打表
King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...
- HDU:2846-Repository
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=2846 Repository Time Limit: 2000/1000 MS (Java/Others) ...
随机推荐
- Jquery自定义扩展方法(二)--HTML日历控件
一.概述 研究了上节的Jquery自定义扩展方法,自己一直想做用jquery写一个小的插件,工作中也用到了用JQuery的日历插件,自己琢磨着去造个轮子--HTML5手机网页日历控件,废话不多说,先看 ...
- Validform 学习笔记---基础知识整理
面对表单的验证,自己写大量的js毕竟不是一个明智的做法.不仅仅是代码很长而且不便于梳理.Validform就是一款开源的第三方验证js的控件,通过添加相应的js以及css能够有效的验证表单,维护起来也 ...
- 2016"百度之星" - 初赛(Astar Round2A)All X(数学 矩阵)
All X Accepts: 1281 Submissions: 7580 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- android 入门-引用库项目
http://blog.csdn.net/arui319/article/details/6831164
- WPF中查看PDF文件
需要打开PDF文件时,我们第一印象就是使用Adobe Reader.在开发中,经常会遇到需要展示PDF文件的需求.我们会借助于Adobe Reader的Active控件来实现.不过这需要客户的机器上安 ...
- C语言文件操作fclose在NDK引起的BUG
今天在NDK中写了一个简单的写入文件操作: FILE *fp = fopen("/sdcard/test.txt","w"); if(fp == NULL) { ...
- 移动 Web 开发技巧
1.使用click会出现绑定点击区域闪一下的情况,解决:给该元素一个样式如下 -webkit-tap-highlight-color: rgba(0,0,0,0); 2.用iphone或ipad浏览很 ...
- 【框架】网络请求+Gson解析--Retrofit 2
其实内部是封装了Okhttp和Gson解析 public class CourseFragmentAPI { public static void get(String userId, BaseCal ...
- JMeter中的关联-正则表达式提取(2)
JMeter获取正则表达式中的提取的所有关联值的解决方法: 需求如下: { : ", : "results": : [ : : { : : : "total_e ...
- 浏览器 - Firefox开发者附加组件
Firefox开发者版本下载地址: https://www.mozilla.org/zh-CN/firefox/channel/desktop/#developer 教程: https://devel ...